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
139,700
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WSelectToggle.java
WSelectToggle.handleRequest
@Override public void handleRequest(final Request request) { if (!isDisabled()) { final SelectToggleModel model = getComponentModel(); String requestParam = request.getParameter(getId()); final State newValue; if ("all".equals(requestParam)) { newValue = State.ALL; } else if ("none".equals(requestParam)) { newValue = State.NONE; } else if ("some".equals(requestParam)) { newValue = State.SOME; } else { newValue = model.state; } if (!newValue.equals(model.state)) { setState(newValue); } if (!model.clientSide && model.target != null && !State.SOME.equals(newValue)) { // We need to change the selections *after* all components // Have updated themselves from the request, as they may change // their values when their handleRequest methods are called. invokeLater(new Runnable() { @Override public void run() { setSelections(model.target, State.ALL.equals(newValue)); } }); } } }
java
@Override public void handleRequest(final Request request) { if (!isDisabled()) { final SelectToggleModel model = getComponentModel(); String requestParam = request.getParameter(getId()); final State newValue; if ("all".equals(requestParam)) { newValue = State.ALL; } else if ("none".equals(requestParam)) { newValue = State.NONE; } else if ("some".equals(requestParam)) { newValue = State.SOME; } else { newValue = model.state; } if (!newValue.equals(model.state)) { setState(newValue); } if (!model.clientSide && model.target != null && !State.SOME.equals(newValue)) { // We need to change the selections *after* all components // Have updated themselves from the request, as they may change // their values when their handleRequest methods are called. invokeLater(new Runnable() { @Override public void run() { setSelections(model.target, State.ALL.equals(newValue)); } }); } } }
[ "@", "Override", "public", "void", "handleRequest", "(", "final", "Request", "request", ")", "{", "if", "(", "!", "isDisabled", "(", ")", ")", "{", "final", "SelectToggleModel", "model", "=", "getComponentModel", "(", ")", ";", "String", "requestParam", "=", "request", ".", "getParameter", "(", "getId", "(", ")", ")", ";", "final", "State", "newValue", ";", "if", "(", "\"all\"", ".", "equals", "(", "requestParam", ")", ")", "{", "newValue", "=", "State", ".", "ALL", ";", "}", "else", "if", "(", "\"none\"", ".", "equals", "(", "requestParam", ")", ")", "{", "newValue", "=", "State", ".", "NONE", ";", "}", "else", "if", "(", "\"some\"", ".", "equals", "(", "requestParam", ")", ")", "{", "newValue", "=", "State", ".", "SOME", ";", "}", "else", "{", "newValue", "=", "model", ".", "state", ";", "}", "if", "(", "!", "newValue", ".", "equals", "(", "model", ".", "state", ")", ")", "{", "setState", "(", "newValue", ")", ";", "}", "if", "(", "!", "model", ".", "clientSide", "&&", "model", ".", "target", "!=", "null", "&&", "!", "State", ".", "SOME", ".", "equals", "(", "newValue", ")", ")", "{", "// We need to change the selections *after* all components", "// Have updated themselves from the request, as they may change", "// their values when their handleRequest methods are called.", "invokeLater", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "setSelections", "(", "model", ".", "target", ",", "State", ".", "ALL", ".", "equals", "(", "newValue", ")", ")", ";", "}", "}", ")", ";", "}", "}", "}" ]
Override handleRequest to handle selection toggling if server-side processing is being used. @param request the request being responded to.
[ "Override", "handleRequest", "to", "handle", "selection", "toggling", "if", "server", "-", "side", "processing", "is", "being", "used", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WSelectToggle.java#L83-L115
139,701
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WSelectToggle.java
WSelectToggle.setSelections
private static void setSelections(final WComponent component, final boolean selected) { if (component instanceof WCheckBox) { ((WCheckBox) component).setSelected(selected); } else if (component instanceof WCheckBoxSelect) { WCheckBoxSelect select = (WCheckBoxSelect) component; select.setSelected(selected ? select.getOptions() : new ArrayList(0)); } else if (component instanceof WMultiSelect) { WMultiSelect list = (WMultiSelect) component; list.setSelected(selected ? list.getOptions() : new ArrayList(0)); } else if (component instanceof WDataTable) { WDataTable table = (WDataTable) component; if (table.getSelectMode() == SelectMode.MULTIPLE) { if (selected) { TableDataModel model = table.getDataModel(); int rowCount = model.getRowCount(); List<Integer> indices = new ArrayList<>(rowCount); for (int i = 0; i < rowCount; i++) { if (model.isSelectable(i)) { indices.add(i); } } table.setSelectedRows(indices); } else { table.setSelectedRows(new ArrayList<Integer>(0)); } } } else if (component instanceof Container) { Container container = (Container) component; final int childCount = container.getChildCount(); for (int i = 0; i < childCount; i++) { WComponent child = container.getChildAt(i); setSelections(child, selected); } } }
java
private static void setSelections(final WComponent component, final boolean selected) { if (component instanceof WCheckBox) { ((WCheckBox) component).setSelected(selected); } else if (component instanceof WCheckBoxSelect) { WCheckBoxSelect select = (WCheckBoxSelect) component; select.setSelected(selected ? select.getOptions() : new ArrayList(0)); } else if (component instanceof WMultiSelect) { WMultiSelect list = (WMultiSelect) component; list.setSelected(selected ? list.getOptions() : new ArrayList(0)); } else if (component instanceof WDataTable) { WDataTable table = (WDataTable) component; if (table.getSelectMode() == SelectMode.MULTIPLE) { if (selected) { TableDataModel model = table.getDataModel(); int rowCount = model.getRowCount(); List<Integer> indices = new ArrayList<>(rowCount); for (int i = 0; i < rowCount; i++) { if (model.isSelectable(i)) { indices.add(i); } } table.setSelectedRows(indices); } else { table.setSelectedRows(new ArrayList<Integer>(0)); } } } else if (component instanceof Container) { Container container = (Container) component; final int childCount = container.getChildCount(); for (int i = 0; i < childCount; i++) { WComponent child = container.getChildAt(i); setSelections(child, selected); } } }
[ "private", "static", "void", "setSelections", "(", "final", "WComponent", "component", ",", "final", "boolean", "selected", ")", "{", "if", "(", "component", "instanceof", "WCheckBox", ")", "{", "(", "(", "WCheckBox", ")", "component", ")", ".", "setSelected", "(", "selected", ")", ";", "}", "else", "if", "(", "component", "instanceof", "WCheckBoxSelect", ")", "{", "WCheckBoxSelect", "select", "=", "(", "WCheckBoxSelect", ")", "component", ";", "select", ".", "setSelected", "(", "selected", "?", "select", ".", "getOptions", "(", ")", ":", "new", "ArrayList", "(", "0", ")", ")", ";", "}", "else", "if", "(", "component", "instanceof", "WMultiSelect", ")", "{", "WMultiSelect", "list", "=", "(", "WMultiSelect", ")", "component", ";", "list", ".", "setSelected", "(", "selected", "?", "list", ".", "getOptions", "(", ")", ":", "new", "ArrayList", "(", "0", ")", ")", ";", "}", "else", "if", "(", "component", "instanceof", "WDataTable", ")", "{", "WDataTable", "table", "=", "(", "WDataTable", ")", "component", ";", "if", "(", "table", ".", "getSelectMode", "(", ")", "==", "SelectMode", ".", "MULTIPLE", ")", "{", "if", "(", "selected", ")", "{", "TableDataModel", "model", "=", "table", ".", "getDataModel", "(", ")", ";", "int", "rowCount", "=", "model", ".", "getRowCount", "(", ")", ";", "List", "<", "Integer", ">", "indices", "=", "new", "ArrayList", "<>", "(", "rowCount", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "rowCount", ";", "i", "++", ")", "{", "if", "(", "model", ".", "isSelectable", "(", "i", ")", ")", "{", "indices", ".", "add", "(", "i", ")", ";", "}", "}", "table", ".", "setSelectedRows", "(", "indices", ")", ";", "}", "else", "{", "table", ".", "setSelectedRows", "(", "new", "ArrayList", "<", "Integer", ">", "(", "0", ")", ")", ";", "}", "}", "}", "else", "if", "(", "component", "instanceof", "Container", ")", "{", "Container", "container", "=", "(", "Container", ")", "component", ";", "final", "int", "childCount", "=", "container", ".", "getChildCount", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "childCount", ";", "i", "++", ")", "{", "WComponent", "child", "=", "container", ".", "getChildAt", "(", "i", ")", ";", "setSelections", "(", "child", ",", "selected", ")", ";", "}", "}", "}" ]
Sets the selections for the given context. @param component the container to modify the selected state for. @param selected if true, select everything. If false, deselect everything.
[ "Sets", "the", "selections", "for", "the", "given", "context", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WSelectToggle.java#L123-L162
139,702
52inc/android-52Kit
library-attributr/src/main/java/com/ftinc/kit/attributr/ui/LibraryAdapter.java
LibraryAdapter.buildSectionHeaders
private void buildSectionHeaders(){ // Update Artist maps HashMap<String, List<com.ftinc.kit.attributr.model.Library>> currMap = new HashMap<>(); // Loop through tuneRefs for(int i=0; i<getItemCount(); i++){ com.ftinc.kit.attributr.model.Library library = getItem(i); String license = library.license.formalName(); List<com.ftinc.kit.attributr.model.Library> libraries = currMap.get(license); if(libraries != null){ libraries.add(library); currMap.put(license, libraries); }else{ libraries = new ArrayList<>(); libraries.add(library); currMap.put(license, libraries); } } // Update maps mHeaders.clear(); mHeaders.addAll(currMap.values()); mTitles.clear(); mTitles.addAll(currMap.keySet()); }
java
private void buildSectionHeaders(){ // Update Artist maps HashMap<String, List<com.ftinc.kit.attributr.model.Library>> currMap = new HashMap<>(); // Loop through tuneRefs for(int i=0; i<getItemCount(); i++){ com.ftinc.kit.attributr.model.Library library = getItem(i); String license = library.license.formalName(); List<com.ftinc.kit.attributr.model.Library> libraries = currMap.get(license); if(libraries != null){ libraries.add(library); currMap.put(license, libraries); }else{ libraries = new ArrayList<>(); libraries.add(library); currMap.put(license, libraries); } } // Update maps mHeaders.clear(); mHeaders.addAll(currMap.values()); mTitles.clear(); mTitles.addAll(currMap.keySet()); }
[ "private", "void", "buildSectionHeaders", "(", ")", "{", "// Update Artist maps", "HashMap", "<", "String", ",", "List", "<", "com", ".", "ftinc", ".", "kit", ".", "attributr", ".", "model", ".", "Library", ">", ">", "currMap", "=", "new", "HashMap", "<>", "(", ")", ";", "// Loop through tuneRefs", "for", "(", "int", "i", "=", "0", ";", "i", "<", "getItemCount", "(", ")", ";", "i", "++", ")", "{", "com", ".", "ftinc", ".", "kit", ".", "attributr", ".", "model", ".", "Library", "library", "=", "getItem", "(", "i", ")", ";", "String", "license", "=", "library", ".", "license", ".", "formalName", "(", ")", ";", "List", "<", "com", ".", "ftinc", ".", "kit", ".", "attributr", ".", "model", ".", "Library", ">", "libraries", "=", "currMap", ".", "get", "(", "license", ")", ";", "if", "(", "libraries", "!=", "null", ")", "{", "libraries", ".", "add", "(", "library", ")", ";", "currMap", ".", "put", "(", "license", ",", "libraries", ")", ";", "}", "else", "{", "libraries", "=", "new", "ArrayList", "<>", "(", ")", ";", "libraries", ".", "add", "(", "library", ")", ";", "currMap", ".", "put", "(", "license", ",", "libraries", ")", ";", "}", "}", "// Update maps", "mHeaders", ".", "clear", "(", ")", ";", "mHeaders", ".", "addAll", "(", "currMap", ".", "values", "(", ")", ")", ";", "mTitles", ".", "clear", "(", ")", ";", "mTitles", ".", "addAll", "(", "currMap", ".", "keySet", "(", ")", ")", ";", "}" ]
Build the section headers for use in creating the headers
[ "Build", "the", "section", "headers", "for", "use", "in", "creating", "the", "headers" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library-attributr/src/main/java/com/ftinc/kit/attributr/ui/LibraryAdapter.java#L118-L142
139,703
52inc/android-52Kit
library-winds/src/main/java/com/ftinc/kit/winds/ui/ChangeLogAdapter.java
ChangeLogAdapter.setChangeLog
public void setChangeLog(ChangeLog log){ mChangeLog = log; // Clear out any existing entries clear(); //sort all the changes Collections.sort(mChangeLog.versions, new VersionComparator()); // Iterate and add all the 'Change' objects in the adapter for(Version version : mChangeLog.versions){ addAll(version.changes); } // Notify content has changed notifyDataSetChanged(); }
java
public void setChangeLog(ChangeLog log){ mChangeLog = log; // Clear out any existing entries clear(); //sort all the changes Collections.sort(mChangeLog.versions, new VersionComparator()); // Iterate and add all the 'Change' objects in the adapter for(Version version : mChangeLog.versions){ addAll(version.changes); } // Notify content has changed notifyDataSetChanged(); }
[ "public", "void", "setChangeLog", "(", "ChangeLog", "log", ")", "{", "mChangeLog", "=", "log", ";", "// Clear out any existing entries", "clear", "(", ")", ";", "//sort all the changes", "Collections", ".", "sort", "(", "mChangeLog", ".", "versions", ",", "new", "VersionComparator", "(", ")", ")", ";", "// Iterate and add all the 'Change' objects in the adapter", "for", "(", "Version", "version", ":", "mChangeLog", ".", "versions", ")", "{", "addAll", "(", "version", ".", "changes", ")", ";", "}", "// Notify content has changed", "notifyDataSetChanged", "(", ")", ";", "}" ]
Set the changelog for this adapter @param log
[ "Set", "the", "changelog", "for", "this", "adapter" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library-winds/src/main/java/com/ftinc/kit/winds/ui/ChangeLogAdapter.java#L63-L79
139,704
52inc/android-52Kit
library-attributr/src/main/java/com/ftinc/kit/attributr/ui/LicenseActivity.java
LicenseActivity.onItemClick
@SuppressLint("NewApi") @Override public void onItemClick(View v, com.ftinc.kit.attributr.model.Library item, int position) { if(BuildUtils.isLollipop()){ v.setElevation(SizeUtils.dpToPx(this, 4)); } View name = ButterKnife.findById(v, R.id.line_1); View author = ButterKnife.findById(v, R.id.line_2); Pair<View, String>[] transitions = new Pair[]{ new Pair<>(v, "display_content"), new Pair<>(name, "library_name"), new Pair<>(author, "library_author"), new Pair<>(mToolbar, "app_bar") }; Intent details = new Intent(this, com.ftinc.kit.attributr.ui.DetailActivity.class); details.putExtra(com.ftinc.kit.attributr.ui.DetailActivity.EXTRA_LIBRARY, item); startActivity(details); // UIUtils.startActivityWithTransition(this, details, transitions); }
java
@SuppressLint("NewApi") @Override public void onItemClick(View v, com.ftinc.kit.attributr.model.Library item, int position) { if(BuildUtils.isLollipop()){ v.setElevation(SizeUtils.dpToPx(this, 4)); } View name = ButterKnife.findById(v, R.id.line_1); View author = ButterKnife.findById(v, R.id.line_2); Pair<View, String>[] transitions = new Pair[]{ new Pair<>(v, "display_content"), new Pair<>(name, "library_name"), new Pair<>(author, "library_author"), new Pair<>(mToolbar, "app_bar") }; Intent details = new Intent(this, com.ftinc.kit.attributr.ui.DetailActivity.class); details.putExtra(com.ftinc.kit.attributr.ui.DetailActivity.EXTRA_LIBRARY, item); startActivity(details); // UIUtils.startActivityWithTransition(this, details, transitions); }
[ "@", "SuppressLint", "(", "\"NewApi\"", ")", "@", "Override", "public", "void", "onItemClick", "(", "View", "v", ",", "com", ".", "ftinc", ".", "kit", ".", "attributr", ".", "model", ".", "Library", "item", ",", "int", "position", ")", "{", "if", "(", "BuildUtils", ".", "isLollipop", "(", ")", ")", "{", "v", ".", "setElevation", "(", "SizeUtils", ".", "dpToPx", "(", "this", ",", "4", ")", ")", ";", "}", "View", "name", "=", "ButterKnife", ".", "findById", "(", "v", ",", "R", ".", "id", ".", "line_1", ")", ";", "View", "author", "=", "ButterKnife", ".", "findById", "(", "v", ",", "R", ".", "id", ".", "line_2", ")", ";", "Pair", "<", "View", ",", "String", ">", "[", "]", "transitions", "=", "new", "Pair", "[", "]", "{", "new", "Pair", "<>", "(", "v", ",", "\"display_content\"", ")", ",", "new", "Pair", "<>", "(", "name", ",", "\"library_name\"", ")", ",", "new", "Pair", "<>", "(", "author", ",", "\"library_author\"", ")", ",", "new", "Pair", "<>", "(", "mToolbar", ",", "\"app_bar\"", ")", "}", ";", "Intent", "details", "=", "new", "Intent", "(", "this", ",", "com", ".", "ftinc", ".", "kit", ".", "attributr", ".", "ui", ".", "DetailActivity", ".", "class", ")", ";", "details", ".", "putExtra", "(", "com", ".", "ftinc", ".", "kit", ".", "attributr", ".", "ui", ".", "DetailActivity", ".", "EXTRA_LIBRARY", ",", "item", ")", ";", "startActivity", "(", "details", ")", ";", "// UIUtils.startActivityWithTransition(this, details, transitions);", "}" ]
Called when a Library item is clicked.
[ "Called", "when", "a", "Library", "item", "is", "clicked", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library-attributr/src/main/java/com/ftinc/kit/attributr/ui/LicenseActivity.java#L137-L159
139,705
52inc/android-52Kit
library-attributr/src/main/java/com/ftinc/kit/attributr/ui/LicenseActivity.java
LicenseActivity.parseExtras
private void parseExtras(Bundle icicle){ Intent intent = getIntent(); if(intent != null){ mXmlConfigId = intent.getIntExtra(EXTRA_CONFIG, -1); mTitle = intent.getStringExtra(EXTRA_TITLE); } if(icicle != null){ mXmlConfigId = icicle.getInt(EXTRA_CONFIG, -1); mTitle = icicle.getString(EXTRA_TITLE); } if(mXmlConfigId == -1) finish(); // Set title if(!TextUtils.isEmpty(mTitle)) getSupportActionBar().setTitle(mTitle); // Apply Configuration List<com.ftinc.kit.attributr.model.Library> libs = com.ftinc.kit.attributr.internal.Parser.parse(this, mXmlConfigId); mAdapter = new com.ftinc.kit.attributr.ui.LibraryAdapter(); mAdapter.addAll(libs); mAdapter.sort(new com.ftinc.kit.attributr.model.Library.LibraryComparator()); mAdapter.notifyDataSetChanged(); }
java
private void parseExtras(Bundle icicle){ Intent intent = getIntent(); if(intent != null){ mXmlConfigId = intent.getIntExtra(EXTRA_CONFIG, -1); mTitle = intent.getStringExtra(EXTRA_TITLE); } if(icicle != null){ mXmlConfigId = icicle.getInt(EXTRA_CONFIG, -1); mTitle = icicle.getString(EXTRA_TITLE); } if(mXmlConfigId == -1) finish(); // Set title if(!TextUtils.isEmpty(mTitle)) getSupportActionBar().setTitle(mTitle); // Apply Configuration List<com.ftinc.kit.attributr.model.Library> libs = com.ftinc.kit.attributr.internal.Parser.parse(this, mXmlConfigId); mAdapter = new com.ftinc.kit.attributr.ui.LibraryAdapter(); mAdapter.addAll(libs); mAdapter.sort(new com.ftinc.kit.attributr.model.Library.LibraryComparator()); mAdapter.notifyDataSetChanged(); }
[ "private", "void", "parseExtras", "(", "Bundle", "icicle", ")", "{", "Intent", "intent", "=", "getIntent", "(", ")", ";", "if", "(", "intent", "!=", "null", ")", "{", "mXmlConfigId", "=", "intent", ".", "getIntExtra", "(", "EXTRA_CONFIG", ",", "-", "1", ")", ";", "mTitle", "=", "intent", ".", "getStringExtra", "(", "EXTRA_TITLE", ")", ";", "}", "if", "(", "icicle", "!=", "null", ")", "{", "mXmlConfigId", "=", "icicle", ".", "getInt", "(", "EXTRA_CONFIG", ",", "-", "1", ")", ";", "mTitle", "=", "icicle", ".", "getString", "(", "EXTRA_TITLE", ")", ";", "}", "if", "(", "mXmlConfigId", "==", "-", "1", ")", "finish", "(", ")", ";", "// Set title", "if", "(", "!", "TextUtils", ".", "isEmpty", "(", "mTitle", ")", ")", "getSupportActionBar", "(", ")", ".", "setTitle", "(", "mTitle", ")", ";", "// Apply Configuration", "List", "<", "com", ".", "ftinc", ".", "kit", ".", "attributr", ".", "model", ".", "Library", ">", "libs", "=", "com", ".", "ftinc", ".", "kit", ".", "attributr", ".", "internal", ".", "Parser", ".", "parse", "(", "this", ",", "mXmlConfigId", ")", ";", "mAdapter", "=", "new", "com", ".", "ftinc", ".", "kit", ".", "attributr", ".", "ui", ".", "LibraryAdapter", "(", ")", ";", "mAdapter", ".", "addAll", "(", "libs", ")", ";", "mAdapter", ".", "sort", "(", "new", "com", ".", "ftinc", ".", "kit", ".", "attributr", ".", "model", ".", "Library", ".", "LibraryComparator", "(", ")", ")", ";", "mAdapter", ".", "notifyDataSetChanged", "(", ")", ";", "}" ]
Parse the Intent or saved bundle extras for the configuration and title data
[ "Parse", "the", "Intent", "or", "saved", "bundle", "extras", "for", "the", "configuration", "and", "title", "data" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library-attributr/src/main/java/com/ftinc/kit/attributr/ui/LicenseActivity.java#L170-L194
139,706
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/BuildUtils.java
BuildUtils.checkForRunningService
public static boolean checkForRunningService(Context ctx, String serviceClassName) { ActivityManager manager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (serviceClassName.equals(service.service.getClassName())) { return true; } } return false; }
java
public static boolean checkForRunningService(Context ctx, String serviceClassName) { ActivityManager manager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (serviceClassName.equals(service.service.getClassName())) { return true; } } return false; }
[ "public", "static", "boolean", "checkForRunningService", "(", "Context", "ctx", ",", "String", "serviceClassName", ")", "{", "ActivityManager", "manager", "=", "(", "ActivityManager", ")", "ctx", ".", "getSystemService", "(", "Context", ".", "ACTIVITY_SERVICE", ")", ";", "for", "(", "ActivityManager", ".", "RunningServiceInfo", "service", ":", "manager", ".", "getRunningServices", "(", "Integer", ".", "MAX_VALUE", ")", ")", "{", "if", "(", "serviceClassName", ".", "equals", "(", "service", ".", "service", ".", "getClassName", "(", ")", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check for a running service @param ctx the application context @param serviceClassName the service class name @return true if service is running, false overwise
[ "Check", "for", "a", "running", "service" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/BuildUtils.java#L120-L128
139,707
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/IntentUtils.java
IntentUtils.openPlayStore
public static Intent openPlayStore(Context context, boolean openInBrowser) { String appPackageName = context.getPackageName(); Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)); if (isIntentAvailable(context, marketIntent)) { return marketIntent; } if (openInBrowser) { return openLink("https://play.google.com/store/apps/details?id=" + appPackageName); } return marketIntent; }
java
public static Intent openPlayStore(Context context, boolean openInBrowser) { String appPackageName = context.getPackageName(); Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)); if (isIntentAvailable(context, marketIntent)) { return marketIntent; } if (openInBrowser) { return openLink("https://play.google.com/store/apps/details?id=" + appPackageName); } return marketIntent; }
[ "public", "static", "Intent", "openPlayStore", "(", "Context", "context", ",", "boolean", "openInBrowser", ")", "{", "String", "appPackageName", "=", "context", ".", "getPackageName", "(", ")", ";", "Intent", "marketIntent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_VIEW", ",", "Uri", ".", "parse", "(", "\"market://details?id=\"", "+", "appPackageName", ")", ")", ";", "if", "(", "isIntentAvailable", "(", "context", ",", "marketIntent", ")", ")", "{", "return", "marketIntent", ";", "}", "if", "(", "openInBrowser", ")", "{", "return", "openLink", "(", "\"https://play.google.com/store/apps/details?id=\"", "+", "appPackageName", ")", ";", "}", "return", "marketIntent", ";", "}" ]
Open app page at Google Play @param context Application context @param openInBrowser Should we try to open application page in web browser if Play Store app not found on device
[ "Open", "app", "page", "at", "Google", "Play" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/IntentUtils.java#L58-L68
139,708
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/IntentUtils.java
IntentUtils.sendEmail
public static Intent sendEmail(String to, String subject, String text) { return sendEmail(new String[]{to}, subject, text); }
java
public static Intent sendEmail(String to, String subject, String text) { return sendEmail(new String[]{to}, subject, text); }
[ "public", "static", "Intent", "sendEmail", "(", "String", "to", ",", "String", "subject", ",", "String", "text", ")", "{", "return", "sendEmail", "(", "new", "String", "[", "]", "{", "to", "}", ",", "subject", ",", "text", ")", ";", "}" ]
Send email message @param to Receiver email @param subject Message subject @param text Message body @see #sendEmail(String[], String, String)
[ "Send", "email", "message" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/IntentUtils.java#L78-L80
139,709
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/IntentUtils.java
IntentUtils.shareText
public static Intent shareText(String subject, String text) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); if (!TextUtils.isEmpty(subject)) { intent.putExtra(Intent.EXTRA_SUBJECT, subject); } intent.putExtra(Intent.EXTRA_TEXT, text); intent.setType("text/plain"); return intent; }
java
public static Intent shareText(String subject, String text) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); if (!TextUtils.isEmpty(subject)) { intent.putExtra(Intent.EXTRA_SUBJECT, subject); } intent.putExtra(Intent.EXTRA_TEXT, text); intent.setType("text/plain"); return intent; }
[ "public", "static", "Intent", "shareText", "(", "String", "subject", ",", "String", "text", ")", "{", "Intent", "intent", "=", "new", "Intent", "(", ")", ";", "intent", ".", "setAction", "(", "Intent", ".", "ACTION_SEND", ")", ";", "if", "(", "!", "TextUtils", ".", "isEmpty", "(", "subject", ")", ")", "{", "intent", ".", "putExtra", "(", "Intent", ".", "EXTRA_SUBJECT", ",", "subject", ")", ";", "}", "intent", ".", "putExtra", "(", "Intent", ".", "EXTRA_TEXT", ",", "text", ")", ";", "intent", ".", "setType", "(", "\"text/plain\"", ")", ";", "return", "intent", ";", "}" ]
Share text via thirdparty app like twitter, facebook, email, sms etc. @param subject Optional subject of the message @param text Text to share
[ "Share", "text", "via", "thirdparty", "app", "like", "twitter", "facebook", "email", "sms", "etc", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/IntentUtils.java#L100-L109
139,710
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/IntentUtils.java
IntentUtils.showLocation
public static Intent showLocation(float latitude, float longitude, Integer zoomLevel) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); String data = String.format("geo:%s,%s", latitude, longitude); if (zoomLevel != null) { data = String.format("%s?z=%s", data, zoomLevel); } intent.setData(Uri.parse(data)); return intent; }
java
public static Intent showLocation(float latitude, float longitude, Integer zoomLevel) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); String data = String.format("geo:%s,%s", latitude, longitude); if (zoomLevel != null) { data = String.format("%s?z=%s", data, zoomLevel); } intent.setData(Uri.parse(data)); return intent; }
[ "public", "static", "Intent", "showLocation", "(", "float", "latitude", ",", "float", "longitude", ",", "Integer", "zoomLevel", ")", "{", "Intent", "intent", "=", "new", "Intent", "(", ")", ";", "intent", ".", "setAction", "(", "Intent", ".", "ACTION_VIEW", ")", ";", "String", "data", "=", "String", ".", "format", "(", "\"geo:%s,%s\"", ",", "latitude", ",", "longitude", ")", ";", "if", "(", "zoomLevel", "!=", "null", ")", "{", "data", "=", "String", ".", "format", "(", "\"%s?z=%s\"", ",", "data", ",", "zoomLevel", ")", ";", "}", "intent", ".", "setData", "(", "Uri", ".", "parse", "(", "data", ")", ")", ";", "return", "intent", ";", "}" ]
Opens the Maps application to the given location. @param latitude Latitude @param longitude Longitude @param zoomLevel A zoom level of 1 shows the whole Earth, centered at the given lat,lng. A zoom level of 2 shows a quarter of the Earth, and so on. The highest zoom level is 23. A larger zoom level will be clamped to 23. @see #findLocation(String)
[ "Opens", "the", "Maps", "application", "to", "the", "given", "location", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/IntentUtils.java#L177-L186
139,711
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/IntentUtils.java
IntentUtils.findLocation
public static Intent findLocation(String query) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); String data = String.format("geo:0,0?q=%s", query); intent.setData(Uri.parse(data)); return intent; }
java
public static Intent findLocation(String query) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); String data = String.format("geo:0,0?q=%s", query); intent.setData(Uri.parse(data)); return intent; }
[ "public", "static", "Intent", "findLocation", "(", "String", "query", ")", "{", "Intent", "intent", "=", "new", "Intent", "(", ")", ";", "intent", ".", "setAction", "(", "Intent", ".", "ACTION_VIEW", ")", ";", "String", "data", "=", "String", ".", "format", "(", "\"geo:0,0?q=%s\"", ",", "query", ")", ";", "intent", ".", "setData", "(", "Uri", ".", "parse", "(", "data", ")", ")", ";", "return", "intent", ";", "}" ]
Opens the Maps application to the given query. @param query Query string @see #showLocation(float, float, Integer)
[ "Opens", "the", "Maps", "application", "to", "the", "given", "query", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/IntentUtils.java#L194-L200
139,712
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/IntentUtils.java
IntentUtils.openLink
public static Intent openLink(String url) { // if protocol isn't defined use http by default if (!TextUtils.isEmpty(url) && !url.contains("://")) { url = "http://" + url; } Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); return intent; }
java
public static Intent openLink(String url) { // if protocol isn't defined use http by default if (!TextUtils.isEmpty(url) && !url.contains("://")) { url = "http://" + url; } Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); return intent; }
[ "public", "static", "Intent", "openLink", "(", "String", "url", ")", "{", "// if protocol isn't defined use http by default", "if", "(", "!", "TextUtils", ".", "isEmpty", "(", "url", ")", "&&", "!", "url", ".", "contains", "(", "\"://\"", ")", ")", "{", "url", "=", "\"http://\"", "+", "url", ";", "}", "Intent", "intent", "=", "new", "Intent", "(", ")", ";", "intent", ".", "setAction", "(", "Intent", ".", "ACTION_VIEW", ")", ";", "intent", ".", "setData", "(", "Uri", ".", "parse", "(", "url", ")", ")", ";", "return", "intent", ";", "}" ]
Open a browser window to the URL specified. @param url Target url
[ "Open", "a", "browser", "window", "to", "the", "URL", "specified", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/IntentUtils.java#L216-L226
139,713
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/IntentUtils.java
IntentUtils.pickImage
public static Intent pickImage() { Intent intent = new Intent(Intent.ACTION_PICK); intent.setType("image/*"); return intent; }
java
public static Intent pickImage() { Intent intent = new Intent(Intent.ACTION_PICK); intent.setType("image/*"); return intent; }
[ "public", "static", "Intent", "pickImage", "(", ")", "{", "Intent", "intent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_PICK", ")", ";", "intent", ".", "setType", "(", "\"image/*\"", ")", ";", "return", "intent", ";", "}" ]
Pick image from gallery
[ "Pick", "image", "from", "gallery" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/IntentUtils.java#L408-L412
139,714
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/IntentUtils.java
IntentUtils.isCropAvailable
public static boolean isCropAvailable(Context context) { Intent intent = new Intent("com.android.camera.action.CROP"); intent.setType("image/*"); return IntentUtils.isIntentAvailable(context, intent); }
java
public static boolean isCropAvailable(Context context) { Intent intent = new Intent("com.android.camera.action.CROP"); intent.setType("image/*"); return IntentUtils.isIntentAvailable(context, intent); }
[ "public", "static", "boolean", "isCropAvailable", "(", "Context", "context", ")", "{", "Intent", "intent", "=", "new", "Intent", "(", "\"com.android.camera.action.CROP\"", ")", ";", "intent", ".", "setType", "(", "\"image/*\"", ")", ";", "return", "IntentUtils", ".", "isIntentAvailable", "(", "context", ",", "intent", ")", ";", "}" ]
Check that cropping application is available @param context Application context @return true if cropping app is available @see #cropImage(android.content.Context, java.io.File, int, int, int, int, boolean)
[ "Check", "that", "cropping", "application", "is", "available" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/IntentUtils.java#L434-L438
139,715
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/IntentUtils.java
IntentUtils.photoCapture
public static Intent photoCapture(String file) { Uri uri = Uri.fromFile(new File(file)); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); return intent; }
java
public static Intent photoCapture(String file) { Uri uri = Uri.fromFile(new File(file)); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); return intent; }
[ "public", "static", "Intent", "photoCapture", "(", "String", "file", ")", "{", "Uri", "uri", "=", "Uri", ".", "fromFile", "(", "new", "File", "(", "file", ")", ")", ";", "Intent", "intent", "=", "new", "Intent", "(", "MediaStore", ".", "ACTION_IMAGE_CAPTURE", ")", ";", "intent", ".", "putExtra", "(", "MediaStore", ".", "EXTRA_OUTPUT", ",", "uri", ")", ";", "return", "intent", ";", "}" ]
Call standard camera application for capturing an image @param file Full path to captured file
[ "Call", "standard", "camera", "application", "for", "capturing", "an", "image" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/IntentUtils.java#L479-L484
139,716
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/IntentUtils.java
IntentUtils.isIntentAvailable
public static boolean isIntentAvailable(Context context, Intent intent) { PackageManager packageManager = context.getPackageManager(); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
java
public static boolean isIntentAvailable(Context context, Intent intent) { PackageManager packageManager = context.getPackageManager(); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
[ "public", "static", "boolean", "isIntentAvailable", "(", "Context", "context", ",", "Intent", "intent", ")", "{", "PackageManager", "packageManager", "=", "context", ".", "getPackageManager", "(", ")", ";", "List", "<", "ResolveInfo", ">", "list", "=", "packageManager", ".", "queryIntentActivities", "(", "intent", ",", "PackageManager", ".", "MATCH_DEFAULT_ONLY", ")", ";", "return", "list", ".", "size", "(", ")", ">", "0", ";", "}" ]
Check that in the system exists application which can handle this intent @param context Application context @param intent Checked intent @return true if intent consumer exists, false otherwise
[ "Check", "that", "in", "the", "system", "exists", "application", "which", "can", "handle", "this", "intent" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/IntentUtils.java#L493-L497
139,717
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/SizeUtils.java
SizeUtils.spToPx
public static float spToPx(Context ctx, float spSize){ return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, spSize, ctx.getResources().getDisplayMetrics()); }
java
public static float spToPx(Context ctx, float spSize){ return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, spSize, ctx.getResources().getDisplayMetrics()); }
[ "public", "static", "float", "spToPx", "(", "Context", "ctx", ",", "float", "spSize", ")", "{", "return", "TypedValue", ".", "applyDimension", "(", "TypedValue", ".", "COMPLEX_UNIT_SP", ",", "spSize", ",", "ctx", ".", "getResources", "(", ")", ".", "getDisplayMetrics", "(", ")", ")", ";", "}" ]
Convert Scale-Dependent Pixels to actual pixels @param ctx the application context @param spSize the size in SP units @return the size in Pixel units
[ "Convert", "Scale", "-", "Dependent", "Pixels", "to", "actual", "pixels" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/SizeUtils.java#L61-L63
139,718
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/widget/ForegroundLinearLayout.java
ForegroundLinearLayout.setForegroundGravity
public void setForegroundGravity(int foregroundGravity) { if (mForegroundGravity != foregroundGravity) { if ((foregroundGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) { foregroundGravity |= Gravity.START; } if ((foregroundGravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) { foregroundGravity |= Gravity.TOP; } mForegroundGravity = foregroundGravity; if (mForegroundGravity == Gravity.FILL && mForeground != null) { Rect padding = new Rect(); mForeground.getPadding(padding); } requestLayout(); } }
java
public void setForegroundGravity(int foregroundGravity) { if (mForegroundGravity != foregroundGravity) { if ((foregroundGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) { foregroundGravity |= Gravity.START; } if ((foregroundGravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) { foregroundGravity |= Gravity.TOP; } mForegroundGravity = foregroundGravity; if (mForegroundGravity == Gravity.FILL && mForeground != null) { Rect padding = new Rect(); mForeground.getPadding(padding); } requestLayout(); } }
[ "public", "void", "setForegroundGravity", "(", "int", "foregroundGravity", ")", "{", "if", "(", "mForegroundGravity", "!=", "foregroundGravity", ")", "{", "if", "(", "(", "foregroundGravity", "&", "Gravity", ".", "RELATIVE_HORIZONTAL_GRAVITY_MASK", ")", "==", "0", ")", "{", "foregroundGravity", "|=", "Gravity", ".", "START", ";", "}", "if", "(", "(", "foregroundGravity", "&", "Gravity", ".", "VERTICAL_GRAVITY_MASK", ")", "==", "0", ")", "{", "foregroundGravity", "|=", "Gravity", ".", "TOP", ";", "}", "mForegroundGravity", "=", "foregroundGravity", ";", "if", "(", "mForegroundGravity", "==", "Gravity", ".", "FILL", "&&", "mForeground", "!=", "null", ")", "{", "Rect", "padding", "=", "new", "Rect", "(", ")", ";", "mForeground", ".", "getPadding", "(", "padding", ")", ";", "}", "requestLayout", "(", ")", ";", "}", "}" ]
Describes how the foreground is positioned. Defaults to START and TOP. @param foregroundGravity See {@link Gravity} @see #getForegroundGravity()
[ "Describes", "how", "the", "foreground", "is", "positioned", ".", "Defaults", "to", "START", "and", "TOP", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/widget/ForegroundLinearLayout.java#L94-L114
139,719
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/widget/ForegroundLinearLayout.java
ForegroundLinearLayout.setForeground
public void setForeground(Drawable drawable) { if (mForeground != drawable) { if (mForeground != null) { mForeground.setCallback(null); unscheduleDrawable(mForeground); } mForeground = drawable; if (drawable != null) { setWillNotDraw(false); drawable.setCallback(this); if (drawable.isStateful()) { drawable.setState(getDrawableState()); } if (mForegroundGravity == Gravity.FILL) { Rect padding = new Rect(); drawable.getPadding(padding); } } else { setWillNotDraw(true); } requestLayout(); invalidate(); } }
java
public void setForeground(Drawable drawable) { if (mForeground != drawable) { if (mForeground != null) { mForeground.setCallback(null); unscheduleDrawable(mForeground); } mForeground = drawable; if (drawable != null) { setWillNotDraw(false); drawable.setCallback(this); if (drawable.isStateful()) { drawable.setState(getDrawableState()); } if (mForegroundGravity == Gravity.FILL) { Rect padding = new Rect(); drawable.getPadding(padding); } } else { setWillNotDraw(true); } requestLayout(); invalidate(); } }
[ "public", "void", "setForeground", "(", "Drawable", "drawable", ")", "{", "if", "(", "mForeground", "!=", "drawable", ")", "{", "if", "(", "mForeground", "!=", "null", ")", "{", "mForeground", ".", "setCallback", "(", "null", ")", ";", "unscheduleDrawable", "(", "mForeground", ")", ";", "}", "mForeground", "=", "drawable", ";", "if", "(", "drawable", "!=", "null", ")", "{", "setWillNotDraw", "(", "false", ")", ";", "drawable", ".", "setCallback", "(", "this", ")", ";", "if", "(", "drawable", ".", "isStateful", "(", ")", ")", "{", "drawable", ".", "setState", "(", "getDrawableState", "(", ")", ")", ";", "}", "if", "(", "mForegroundGravity", "==", "Gravity", ".", "FILL", ")", "{", "Rect", "padding", "=", "new", "Rect", "(", ")", ";", "drawable", ".", "getPadding", "(", "padding", ")", ";", "}", "}", "else", "{", "setWillNotDraw", "(", "true", ")", ";", "}", "requestLayout", "(", ")", ";", "invalidate", "(", ")", ";", "}", "}" ]
Supply a Drawable that is to be rendered on top of all of the child views in the frame layout. Any padding in the Drawable will be taken into account by ensuring that the children are inset to be placed inside of the padding area. @param drawable The Drawable to be drawn on top of the children.
[ "Supply", "a", "Drawable", "that", "is", "to", "be", "rendered", "on", "top", "of", "all", "of", "the", "child", "views", "in", "the", "frame", "layout", ".", "Any", "padding", "in", "the", "Drawable", "will", "be", "taken", "into", "account", "by", "ensuring", "that", "the", "children", "are", "inset", "to", "be", "placed", "inside", "of", "the", "padding", "area", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/widget/ForegroundLinearLayout.java#L143-L168
139,720
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/FileUtils.java
FileUtils.crapToDisk
public static int crapToDisk(Context ctx, String filename, byte[] data){ int code = IO_FAIL; File dir = Environment.getExternalStorageDirectory(); File output = new File(dir, filename); try { FileOutputStream fos = new FileOutputStream(output); try { fos.write(data); code = IO_SUCCESS; } catch (IOException e) { code = IO_FAIL; } finally { fos.close(); } } catch (IOException e) { e.printStackTrace(); } return code; }
java
public static int crapToDisk(Context ctx, String filename, byte[] data){ int code = IO_FAIL; File dir = Environment.getExternalStorageDirectory(); File output = new File(dir, filename); try { FileOutputStream fos = new FileOutputStream(output); try { fos.write(data); code = IO_SUCCESS; } catch (IOException e) { code = IO_FAIL; } finally { fos.close(); } } catch (IOException e) { e.printStackTrace(); } return code; }
[ "public", "static", "int", "crapToDisk", "(", "Context", "ctx", ",", "String", "filename", ",", "byte", "[", "]", "data", ")", "{", "int", "code", "=", "IO_FAIL", ";", "File", "dir", "=", "Environment", ".", "getExternalStorageDirectory", "(", ")", ";", "File", "output", "=", "new", "File", "(", "dir", ",", "filename", ")", ";", "try", "{", "FileOutputStream", "fos", "=", "new", "FileOutputStream", "(", "output", ")", ";", "try", "{", "fos", ".", "write", "(", "data", ")", ";", "code", "=", "IO_SUCCESS", ";", "}", "catch", "(", "IOException", "e", ")", "{", "code", "=", "IO_FAIL", ";", "}", "finally", "{", "fos", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "code", ";", "}" ]
Dump Data straight to the SDCard @param ctx the application context @param filename the dump filename @param data the data to dump @return the return
[ "Dump", "Data", "straight", "to", "the", "SDCard" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/FileUtils.java#L196-L217
139,721
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/FileUtils.java
FileUtils.getVideoThumbnail
public static Bitmap getVideoThumbnail(String videoPath){ MediaMetadataRetriever mmr = new MediaMetadataRetriever(); mmr.setDataSource(videoPath); return mmr.getFrameAtTime(); }
java
public static Bitmap getVideoThumbnail(String videoPath){ MediaMetadataRetriever mmr = new MediaMetadataRetriever(); mmr.setDataSource(videoPath); return mmr.getFrameAtTime(); }
[ "public", "static", "Bitmap", "getVideoThumbnail", "(", "String", "videoPath", ")", "{", "MediaMetadataRetriever", "mmr", "=", "new", "MediaMetadataRetriever", "(", ")", ";", "mmr", ".", "setDataSource", "(", "videoPath", ")", ";", "return", "mmr", ".", "getFrameAtTime", "(", ")", ";", "}" ]
Get a thumbnail bitmap for a given video @param videoPath the path to the video @return the thumbnail of the video, or null
[ "Get", "a", "thumbnail", "bitmap", "for", "a", "given", "video" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/FileUtils.java#L302-L306
139,722
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/FileUtils.java
FileUtils.getVideoThumbnail
public static void getVideoThumbnail(String videoPath, final VideoThumbnailCallback cb){ new AsyncTask<String, Void, Bitmap>(){ @Override protected Bitmap doInBackground(String... params) { if(params.length > 0) { String path = params[0]; if(!TextUtils.isEmpty(path)){ return getVideoThumbnail(path); } } return null; } @Override protected void onPostExecute(Bitmap bitmap) { cb.onThumbnail(bitmap); } }.execute(videoPath); }
java
public static void getVideoThumbnail(String videoPath, final VideoThumbnailCallback cb){ new AsyncTask<String, Void, Bitmap>(){ @Override protected Bitmap doInBackground(String... params) { if(params.length > 0) { String path = params[0]; if(!TextUtils.isEmpty(path)){ return getVideoThumbnail(path); } } return null; } @Override protected void onPostExecute(Bitmap bitmap) { cb.onThumbnail(bitmap); } }.execute(videoPath); }
[ "public", "static", "void", "getVideoThumbnail", "(", "String", "videoPath", ",", "final", "VideoThumbnailCallback", "cb", ")", "{", "new", "AsyncTask", "<", "String", ",", "Void", ",", "Bitmap", ">", "(", ")", "{", "@", "Override", "protected", "Bitmap", "doInBackground", "(", "String", "...", "params", ")", "{", "if", "(", "params", ".", "length", ">", "0", ")", "{", "String", "path", "=", "params", "[", "0", "]", ";", "if", "(", "!", "TextUtils", ".", "isEmpty", "(", "path", ")", ")", "{", "return", "getVideoThumbnail", "(", "path", ")", ";", "}", "}", "return", "null", ";", "}", "@", "Override", "protected", "void", "onPostExecute", "(", "Bitmap", "bitmap", ")", "{", "cb", ".", "onThumbnail", "(", "bitmap", ")", ";", "}", "}", ".", "execute", "(", "videoPath", ")", ";", "}" ]
Get the thumbnail of a video asynchronously @param videoPath the path to the video @param cb the callback
[ "Get", "the", "thumbnail", "of", "a", "video", "asynchronously" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/FileUtils.java#L314-L332
139,723
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/FileUtils.java
FileUtils.copy
public static boolean copy(File source, File output){ // Check to see if output exists if(output.exists() && output.canWrite()){ // Delete the existing file, and create a new one if(output.delete()) { try { output.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } }else if(!output.exists()){ try { output.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } // now that we have performed a prelimanary check on the output, time to copy if(source.exists() && source.canRead()){ try { FileInputStream fis = new FileInputStream(source); FileOutputStream fos = new FileOutputStream(output); byte[] buffer = new byte[1024]; int len=0; while((len=fis.read(buffer)) > 0){ fos.write(buffer, 0, len); } fis.close(); fos.close(); return true; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } return false; }
java
public static boolean copy(File source, File output){ // Check to see if output exists if(output.exists() && output.canWrite()){ // Delete the existing file, and create a new one if(output.delete()) { try { output.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } }else if(!output.exists()){ try { output.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } // now that we have performed a prelimanary check on the output, time to copy if(source.exists() && source.canRead()){ try { FileInputStream fis = new FileInputStream(source); FileOutputStream fos = new FileOutputStream(output); byte[] buffer = new byte[1024]; int len=0; while((len=fis.read(buffer)) > 0){ fos.write(buffer, 0, len); } fis.close(); fos.close(); return true; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } return false; }
[ "public", "static", "boolean", "copy", "(", "File", "source", ",", "File", "output", ")", "{", "// Check to see if output exists", "if", "(", "output", ".", "exists", "(", ")", "&&", "output", ".", "canWrite", "(", ")", ")", "{", "// Delete the existing file, and create a new one", "if", "(", "output", ".", "delete", "(", ")", ")", "{", "try", "{", "output", ".", "createNewFile", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "else", "if", "(", "!", "output", ".", "exists", "(", ")", ")", "{", "try", "{", "output", ".", "createNewFile", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "// now that we have performed a prelimanary check on the output, time to copy", "if", "(", "source", ".", "exists", "(", ")", "&&", "source", ".", "canRead", "(", ")", ")", "{", "try", "{", "FileInputStream", "fis", "=", "new", "FileInputStream", "(", "source", ")", ";", "FileOutputStream", "fos", "=", "new", "FileOutputStream", "(", "output", ")", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "1024", "]", ";", "int", "len", "=", "0", ";", "while", "(", "(", "len", "=", "fis", ".", "read", "(", "buffer", ")", ")", ">", "0", ")", "{", "fos", ".", "write", "(", "buffer", ",", "0", ",", "len", ")", ";", "}", "fis", ".", "close", "(", ")", ";", "fos", ".", "close", "(", ")", ";", "return", "true", ";", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "return", "false", ";", "}" ]
Copy a file from it's source input to the specified output file if it can. @param source the input file to copy @param output the output destination @return true if successful, false otherwise
[ "Copy", "a", "file", "from", "it", "s", "source", "input", "to", "the", "specified", "output", "file", "if", "it", "can", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/FileUtils.java#L342-L388
139,724
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/TimeUtils.java
TimeUtils.fancyTimestamp
public static String fancyTimestamp(long epoch){ // First, check to see if it's within 1 minute of the current date if(System.currentTimeMillis() - epoch < 60000){ return "Just now"; } // Get calendar for just now Calendar now = Calendar.getInstance(); // Generate Calendar for this time Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(epoch); // Based on the date, determine what to print out // 1) Determine if time is the same day if(cal.get(YEAR) == now.get(YEAR)){ if(cal.get(MONTH) == now.get(MONTH)){ if(cal.get(DAY_OF_MONTH) == now.get(DAY_OF_MONTH)){ // Return just the time SimpleDateFormat format = new SimpleDateFormat("h:mm a"); return format.format(cal.getTime()); } else { // Return the day and time SimpleDateFormat format = new SimpleDateFormat("EEE, h:mm a"); return format.format(cal.getTime()); } }else{ SimpleDateFormat format = new SimpleDateFormat("EEE, MMM d, h:mm a"); return format.format(cal.getTime()); } }else{ SimpleDateFormat format = new SimpleDateFormat("M/d/yy"); return format.format(cal.getTime()); } }
java
public static String fancyTimestamp(long epoch){ // First, check to see if it's within 1 minute of the current date if(System.currentTimeMillis() - epoch < 60000){ return "Just now"; } // Get calendar for just now Calendar now = Calendar.getInstance(); // Generate Calendar for this time Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(epoch); // Based on the date, determine what to print out // 1) Determine if time is the same day if(cal.get(YEAR) == now.get(YEAR)){ if(cal.get(MONTH) == now.get(MONTH)){ if(cal.get(DAY_OF_MONTH) == now.get(DAY_OF_MONTH)){ // Return just the time SimpleDateFormat format = new SimpleDateFormat("h:mm a"); return format.format(cal.getTime()); } else { // Return the day and time SimpleDateFormat format = new SimpleDateFormat("EEE, h:mm a"); return format.format(cal.getTime()); } }else{ SimpleDateFormat format = new SimpleDateFormat("EEE, MMM d, h:mm a"); return format.format(cal.getTime()); } }else{ SimpleDateFormat format = new SimpleDateFormat("M/d/yy"); return format.format(cal.getTime()); } }
[ "public", "static", "String", "fancyTimestamp", "(", "long", "epoch", ")", "{", "// First, check to see if it's within 1 minute of the current date", "if", "(", "System", ".", "currentTimeMillis", "(", ")", "-", "epoch", "<", "60000", ")", "{", "return", "\"Just now\"", ";", "}", "// Get calendar for just now", "Calendar", "now", "=", "Calendar", ".", "getInstance", "(", ")", ";", "// Generate Calendar for this time", "Calendar", "cal", "=", "Calendar", ".", "getInstance", "(", ")", ";", "cal", ".", "setTimeInMillis", "(", "epoch", ")", ";", "// Based on the date, determine what to print out", "// 1) Determine if time is the same day", "if", "(", "cal", ".", "get", "(", "YEAR", ")", "==", "now", ".", "get", "(", "YEAR", ")", ")", "{", "if", "(", "cal", ".", "get", "(", "MONTH", ")", "==", "now", ".", "get", "(", "MONTH", ")", ")", "{", "if", "(", "cal", ".", "get", "(", "DAY_OF_MONTH", ")", "==", "now", ".", "get", "(", "DAY_OF_MONTH", ")", ")", "{", "// Return just the time", "SimpleDateFormat", "format", "=", "new", "SimpleDateFormat", "(", "\"h:mm a\"", ")", ";", "return", "format", ".", "format", "(", "cal", ".", "getTime", "(", ")", ")", ";", "}", "else", "{", "// Return the day and time", "SimpleDateFormat", "format", "=", "new", "SimpleDateFormat", "(", "\"EEE, h:mm a\"", ")", ";", "return", "format", ".", "format", "(", "cal", ".", "getTime", "(", ")", ")", ";", "}", "}", "else", "{", "SimpleDateFormat", "format", "=", "new", "SimpleDateFormat", "(", "\"EEE, MMM d, h:mm a\"", ")", ";", "return", "format", ".", "format", "(", "cal", ".", "getTime", "(", ")", ")", ";", "}", "}", "else", "{", "SimpleDateFormat", "format", "=", "new", "SimpleDateFormat", "(", "\"M/d/yy\"", ")", ";", "return", "format", ".", "format", "(", "cal", ".", "getTime", "(", ")", ")", ";", "}", "}" ]
Generate a fancy timestamp based on unix epoch time that is more user friendly than just a raw output by collapsing the time into manageable formats based on how much time has elapsed since epoch @param epoch the time in unix epoch @return the fancy timestamp
[ "Generate", "a", "fancy", "timestamp", "based", "on", "unix", "epoch", "time", "that", "is", "more", "user", "friendly", "than", "just", "a", "raw", "output", "by", "collapsing", "the", "time", "into", "manageable", "formats", "based", "on", "how", "much", "time", "has", "elapsed", "since", "epoch" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/TimeUtils.java#L91-L136
139,725
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/TimeUtils.java
TimeUtils.formatHumanFriendlyShortDate
public static String formatHumanFriendlyShortDate(final Context context, long timestamp) { long localTimestamp, localTime; long now = System.currentTimeMillis(); TimeZone tz = TimeZone.getDefault(); localTimestamp = timestamp + tz.getOffset(timestamp); localTime = now + tz.getOffset(now); long dayOrd = localTimestamp / 86400000L; long nowOrd = localTime / 86400000L; if (dayOrd == nowOrd) { return context.getString(R.string.day_title_today); } else if (dayOrd == nowOrd - 1) { return context.getString(R.string.day_title_yesterday); } else if (dayOrd == nowOrd + 1) { return context.getString(R.string.day_title_tomorrow); } else { return formatShortDate(context, new Date(timestamp)); } }
java
public static String formatHumanFriendlyShortDate(final Context context, long timestamp) { long localTimestamp, localTime; long now = System.currentTimeMillis(); TimeZone tz = TimeZone.getDefault(); localTimestamp = timestamp + tz.getOffset(timestamp); localTime = now + tz.getOffset(now); long dayOrd = localTimestamp / 86400000L; long nowOrd = localTime / 86400000L; if (dayOrd == nowOrd) { return context.getString(R.string.day_title_today); } else if (dayOrd == nowOrd - 1) { return context.getString(R.string.day_title_yesterday); } else if (dayOrd == nowOrd + 1) { return context.getString(R.string.day_title_tomorrow); } else { return formatShortDate(context, new Date(timestamp)); } }
[ "public", "static", "String", "formatHumanFriendlyShortDate", "(", "final", "Context", "context", ",", "long", "timestamp", ")", "{", "long", "localTimestamp", ",", "localTime", ";", "long", "now", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "TimeZone", "tz", "=", "TimeZone", ".", "getDefault", "(", ")", ";", "localTimestamp", "=", "timestamp", "+", "tz", ".", "getOffset", "(", "timestamp", ")", ";", "localTime", "=", "now", "+", "tz", ".", "getOffset", "(", "now", ")", ";", "long", "dayOrd", "=", "localTimestamp", "/", "86400000L", ";", "long", "nowOrd", "=", "localTime", "/", "86400000L", ";", "if", "(", "dayOrd", "==", "nowOrd", ")", "{", "return", "context", ".", "getString", "(", "R", ".", "string", ".", "day_title_today", ")", ";", "}", "else", "if", "(", "dayOrd", "==", "nowOrd", "-", "1", ")", "{", "return", "context", ".", "getString", "(", "R", ".", "string", ".", "day_title_yesterday", ")", ";", "}", "else", "if", "(", "dayOrd", "==", "nowOrd", "+", "1", ")", "{", "return", "context", ".", "getString", "(", "R", ".", "string", ".", "day_title_tomorrow", ")", ";", "}", "else", "{", "return", "formatShortDate", "(", "context", ",", "new", "Date", "(", "timestamp", ")", ")", ";", "}", "}" ]
Returns "Today", "Tomorrow", "Yesterday", or a short date format.
[ "Returns", "Today", "Tomorrow", "Yesterday", "or", "a", "short", "date", "format", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/TimeUtils.java#L141-L161
139,726
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/ColorUtils.java
ColorUtils.isColorDark
public static boolean isColorDark(int color) { return ((30 * Color.red(color) + 59 * Color.green(color) + 11 * Color.blue(color)) / 100) <= BRIGHTNESS_THRESHOLD; }
java
public static boolean isColorDark(int color) { return ((30 * Color.red(color) + 59 * Color.green(color) + 11 * Color.blue(color)) / 100) <= BRIGHTNESS_THRESHOLD; }
[ "public", "static", "boolean", "isColorDark", "(", "int", "color", ")", "{", "return", "(", "(", "30", "*", "Color", ".", "red", "(", "color", ")", "+", "59", "*", "Color", ".", "green", "(", "color", ")", "+", "11", "*", "Color", ".", "blue", "(", "color", ")", ")", "/", "100", ")", "<=", "BRIGHTNESS_THRESHOLD", ";", "}" ]
Calculate whether a color is light or dark, based on a commonly known brightness formula. @see <a href="http://en.wikipedia.org/wiki/HSV_color_space%23Lightness">http://en.wikipedia.org/wiki/HSV_color_space%23Lightness</a>
[ "Calculate", "whether", "a", "color", "is", "light", "or", "dark", "based", "on", "a", "commonly", "known", "brightness", "formula", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/ColorUtils.java#L95-L99
139,727
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/adapter/BetterListAdapter.java
BetterListAdapter.getView
@Override public View getView(int position, View convertView, ViewGroup parent){ VH holder; if(convertView == null){ // Load the view from scratch convertView = inflater.inflate(viewResource, parent, false); // Load the ViewHolder holder = createHolder(convertView); // set holder to the tag convertView.setTag(holder); }else{ // Pull the view holder from convertView's tag holder = (VH) convertView.getTag(); } // bind the data to the holder bindHolder(holder, position, getItem(position)); return convertView; }
java
@Override public View getView(int position, View convertView, ViewGroup parent){ VH holder; if(convertView == null){ // Load the view from scratch convertView = inflater.inflate(viewResource, parent, false); // Load the ViewHolder holder = createHolder(convertView); // set holder to the tag convertView.setTag(holder); }else{ // Pull the view holder from convertView's tag holder = (VH) convertView.getTag(); } // bind the data to the holder bindHolder(holder, position, getItem(position)); return convertView; }
[ "@", "Override", "public", "View", "getView", "(", "int", "position", ",", "View", "convertView", ",", "ViewGroup", "parent", ")", "{", "VH", "holder", ";", "if", "(", "convertView", "==", "null", ")", "{", "// Load the view from scratch", "convertView", "=", "inflater", ".", "inflate", "(", "viewResource", ",", "parent", ",", "false", ")", ";", "// Load the ViewHolder", "holder", "=", "createHolder", "(", "convertView", ")", ";", "// set holder to the tag", "convertView", ".", "setTag", "(", "holder", ")", ";", "}", "else", "{", "// Pull the view holder from convertView's tag", "holder", "=", "(", "VH", ")", "convertView", ".", "getTag", "(", ")", ";", "}", "// bind the data to the holder", "bindHolder", "(", "holder", ",", "position", ",", "getItem", "(", "position", ")", ")", ";", "return", "convertView", ";", "}" ]
Called to retrieve the view
[ "Called", "to", "retrieve", "the", "view" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/adapter/BetterListAdapter.java#L71-L99
139,728
52inc/android-52Kit
library-winds/src/main/java/com/ftinc/kit/winds/Winds.java
Winds.validateVersion
private static boolean validateVersion(Context ctx, ChangeLog clog){ // Get Preferences SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); int lastSeen = prefs.getInt(PREF_CHANGELOG_LAST_SEEN, -1); // Second sort versions by it's code int latest = Integer.MIN_VALUE; for(Version version: clog.versions){ if(version.code > latest){ latest = version.code; } } // Get applications current version if(latest > lastSeen){ if(!BuildConfig.DEBUG) prefs.edit().putInt(PREF_CHANGELOG_LAST_SEEN, latest).apply(); return true; } return false; }
java
private static boolean validateVersion(Context ctx, ChangeLog clog){ // Get Preferences SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); int lastSeen = prefs.getInt(PREF_CHANGELOG_LAST_SEEN, -1); // Second sort versions by it's code int latest = Integer.MIN_VALUE; for(Version version: clog.versions){ if(version.code > latest){ latest = version.code; } } // Get applications current version if(latest > lastSeen){ if(!BuildConfig.DEBUG) prefs.edit().putInt(PREF_CHANGELOG_LAST_SEEN, latest).apply(); return true; } return false; }
[ "private", "static", "boolean", "validateVersion", "(", "Context", "ctx", ",", "ChangeLog", "clog", ")", "{", "// Get Preferences", "SharedPreferences", "prefs", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "ctx", ")", ";", "int", "lastSeen", "=", "prefs", ".", "getInt", "(", "PREF_CHANGELOG_LAST_SEEN", ",", "-", "1", ")", ";", "// Second sort versions by it's code", "int", "latest", "=", "Integer", ".", "MIN_VALUE", ";", "for", "(", "Version", "version", ":", "clog", ".", "versions", ")", "{", "if", "(", "version", ".", "code", ">", "latest", ")", "{", "latest", "=", "version", ".", "code", ";", "}", "}", "// Get applications current version", "if", "(", "latest", ">", "lastSeen", ")", "{", "if", "(", "!", "BuildConfig", ".", "DEBUG", ")", "prefs", ".", "edit", "(", ")", ".", "putInt", "(", "PREF_CHANGELOG_LAST_SEEN", ",", "latest", ")", ".", "apply", "(", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Validate the last seen stored verion code against the current changelog configuration to see if there is any updates and whether or not we should show the changelog dialog when called. @param ctx @param clog @return
[ "Validate", "the", "last", "seen", "stored", "verion", "code", "against", "the", "current", "changelog", "configuration", "to", "see", "if", "there", "is", "any", "updates", "and", "whether", "or", "not", "we", "should", "show", "the", "changelog", "dialog", "when", "called", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library-winds/src/main/java/com/ftinc/kit/winds/Winds.java#L190-L211
139,729
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/CompositeTextWatcher.java
CompositeTextWatcher.enableWatcher
public void enableWatcher(TextWatcher watcher, boolean enabled){ int index = mWatchers.indexOfValue(watcher); if(index >= 0){ int key = mWatchers.keyAt(index); mEnabledKeys.put(key, enabled); } }
java
public void enableWatcher(TextWatcher watcher, boolean enabled){ int index = mWatchers.indexOfValue(watcher); if(index >= 0){ int key = mWatchers.keyAt(index); mEnabledKeys.put(key, enabled); } }
[ "public", "void", "enableWatcher", "(", "TextWatcher", "watcher", ",", "boolean", "enabled", ")", "{", "int", "index", "=", "mWatchers", ".", "indexOfValue", "(", "watcher", ")", ";", "if", "(", "index", ">=", "0", ")", "{", "int", "key", "=", "mWatchers", ".", "keyAt", "(", "index", ")", ";", "mEnabledKeys", ".", "put", "(", "key", ",", "enabled", ")", ";", "}", "}" ]
Enable or Disable a text watcher by reference @param watcher The {@link TextWatcher} to enable or disable @param enabled whether or not to enable or disable
[ "Enable", "or", "Disable", "a", "text", "watcher", "by", "reference" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/CompositeTextWatcher.java#L130-L136
139,730
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/widget/EmptyView.java
EmptyView.parseAttributes
private void parseAttributes(Context context, AttributeSet attrs, int defStyle){ int defaultColor = context.getResources().getColor(R.color.black26); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EmptyView, defStyle, 0); if (a == null) { mEmptyMessageColor = defaultColor; mEmptyActionColor = defaultColor; mEmptyMessageTextSize = (int) SizeUtils.dpToPx(context, 18); mEmptyActionTextSize = (int) SizeUtils.dpToPx(context, 14); mEmptyMessageTypeface = Face.ROBOTO_REGULAR; mEmptyIconPadding = getResources().getDimensionPixelSize(R.dimen.activity_padding); return; } // Parse attributes mEmptyIcon = a.getResourceId(R.styleable.EmptyView_emptyIcon, -1); mEmptyIconSize = a.getDimensionPixelSize(R.styleable.EmptyView_emptyIconSize, -1); mEmptyIconColor = a.getColor(R.styleable.EmptyView_emptyIconColor, defaultColor); mEmptyIconPadding = a.getDimensionPixelSize(R.styleable.EmptyView_emptyIconPadding, getResources().getDimensionPixelSize(R.dimen.activity_padding)); mEmptyMessage = a.getString(R.styleable.EmptyView_emptyMessage); mEmptyMessageColor = a.getColor(R.styleable.EmptyView_emptyMessageColor, defaultColor); int typeface = a.getInt(R.styleable.EmptyView_emptyMessageTypeface, 0); mEmptyMessageTypeface = MessageTypeface.from(typeface).getTypeface(); mEmptyMessageTextSize = a.getDimensionPixelSize(R.styleable.EmptyView_emptyMessageTextSize, (int) SizeUtils.dpToPx(context, 18)); mEmptyActionColor = a.getColor(R.styleable.EmptyView_emptyActionColor, defaultColor); mEmptyActionText = a.getString(R.styleable.EmptyView_emptyActionText); mEmptyActionTextSize = a.getDimensionPixelSize(R.styleable.EmptyView_emptyActionTextSize, (int) SizeUtils.dpToPx(context, 14)); mState = a.getInt(R.styleable.EmptyView_emptyState, STATE_EMPTY); a.recycle(); }
java
private void parseAttributes(Context context, AttributeSet attrs, int defStyle){ int defaultColor = context.getResources().getColor(R.color.black26); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EmptyView, defStyle, 0); if (a == null) { mEmptyMessageColor = defaultColor; mEmptyActionColor = defaultColor; mEmptyMessageTextSize = (int) SizeUtils.dpToPx(context, 18); mEmptyActionTextSize = (int) SizeUtils.dpToPx(context, 14); mEmptyMessageTypeface = Face.ROBOTO_REGULAR; mEmptyIconPadding = getResources().getDimensionPixelSize(R.dimen.activity_padding); return; } // Parse attributes mEmptyIcon = a.getResourceId(R.styleable.EmptyView_emptyIcon, -1); mEmptyIconSize = a.getDimensionPixelSize(R.styleable.EmptyView_emptyIconSize, -1); mEmptyIconColor = a.getColor(R.styleable.EmptyView_emptyIconColor, defaultColor); mEmptyIconPadding = a.getDimensionPixelSize(R.styleable.EmptyView_emptyIconPadding, getResources().getDimensionPixelSize(R.dimen.activity_padding)); mEmptyMessage = a.getString(R.styleable.EmptyView_emptyMessage); mEmptyMessageColor = a.getColor(R.styleable.EmptyView_emptyMessageColor, defaultColor); int typeface = a.getInt(R.styleable.EmptyView_emptyMessageTypeface, 0); mEmptyMessageTypeface = MessageTypeface.from(typeface).getTypeface(); mEmptyMessageTextSize = a.getDimensionPixelSize(R.styleable.EmptyView_emptyMessageTextSize, (int) SizeUtils.dpToPx(context, 18)); mEmptyActionColor = a.getColor(R.styleable.EmptyView_emptyActionColor, defaultColor); mEmptyActionText = a.getString(R.styleable.EmptyView_emptyActionText); mEmptyActionTextSize = a.getDimensionPixelSize(R.styleable.EmptyView_emptyActionTextSize, (int) SizeUtils.dpToPx(context, 14)); mState = a.getInt(R.styleable.EmptyView_emptyState, STATE_EMPTY); a.recycle(); }
[ "private", "void", "parseAttributes", "(", "Context", "context", ",", "AttributeSet", "attrs", ",", "int", "defStyle", ")", "{", "int", "defaultColor", "=", "context", ".", "getResources", "(", ")", ".", "getColor", "(", "R", ".", "color", ".", "black26", ")", ";", "final", "TypedArray", "a", "=", "context", ".", "obtainStyledAttributes", "(", "attrs", ",", "R", ".", "styleable", ".", "EmptyView", ",", "defStyle", ",", "0", ")", ";", "if", "(", "a", "==", "null", ")", "{", "mEmptyMessageColor", "=", "defaultColor", ";", "mEmptyActionColor", "=", "defaultColor", ";", "mEmptyMessageTextSize", "=", "(", "int", ")", "SizeUtils", ".", "dpToPx", "(", "context", ",", "18", ")", ";", "mEmptyActionTextSize", "=", "(", "int", ")", "SizeUtils", ".", "dpToPx", "(", "context", ",", "14", ")", ";", "mEmptyMessageTypeface", "=", "Face", ".", "ROBOTO_REGULAR", ";", "mEmptyIconPadding", "=", "getResources", "(", ")", ".", "getDimensionPixelSize", "(", "R", ".", "dimen", ".", "activity_padding", ")", ";", "return", ";", "}", "// Parse attributes", "mEmptyIcon", "=", "a", ".", "getResourceId", "(", "R", ".", "styleable", ".", "EmptyView_emptyIcon", ",", "-", "1", ")", ";", "mEmptyIconSize", "=", "a", ".", "getDimensionPixelSize", "(", "R", ".", "styleable", ".", "EmptyView_emptyIconSize", ",", "-", "1", ")", ";", "mEmptyIconColor", "=", "a", ".", "getColor", "(", "R", ".", "styleable", ".", "EmptyView_emptyIconColor", ",", "defaultColor", ")", ";", "mEmptyIconPadding", "=", "a", ".", "getDimensionPixelSize", "(", "R", ".", "styleable", ".", "EmptyView_emptyIconPadding", ",", "getResources", "(", ")", ".", "getDimensionPixelSize", "(", "R", ".", "dimen", ".", "activity_padding", ")", ")", ";", "mEmptyMessage", "=", "a", ".", "getString", "(", "R", ".", "styleable", ".", "EmptyView_emptyMessage", ")", ";", "mEmptyMessageColor", "=", "a", ".", "getColor", "(", "R", ".", "styleable", ".", "EmptyView_emptyMessageColor", ",", "defaultColor", ")", ";", "int", "typeface", "=", "a", ".", "getInt", "(", "R", ".", "styleable", ".", "EmptyView_emptyMessageTypeface", ",", "0", ")", ";", "mEmptyMessageTypeface", "=", "MessageTypeface", ".", "from", "(", "typeface", ")", ".", "getTypeface", "(", ")", ";", "mEmptyMessageTextSize", "=", "a", ".", "getDimensionPixelSize", "(", "R", ".", "styleable", ".", "EmptyView_emptyMessageTextSize", ",", "(", "int", ")", "SizeUtils", ".", "dpToPx", "(", "context", ",", "18", ")", ")", ";", "mEmptyActionColor", "=", "a", ".", "getColor", "(", "R", ".", "styleable", ".", "EmptyView_emptyActionColor", ",", "defaultColor", ")", ";", "mEmptyActionText", "=", "a", ".", "getString", "(", "R", ".", "styleable", ".", "EmptyView_emptyActionText", ")", ";", "mEmptyActionTextSize", "=", "a", ".", "getDimensionPixelSize", "(", "R", ".", "styleable", ".", "EmptyView_emptyActionTextSize", ",", "(", "int", ")", "SizeUtils", ".", "dpToPx", "(", "context", ",", "14", ")", ")", ";", "mState", "=", "a", ".", "getInt", "(", "R", ".", "styleable", ".", "EmptyView_emptyState", ",", "STATE_EMPTY", ")", ";", "a", ".", "recycle", "(", ")", ";", "}" ]
Parse XML attributes @param attrs the attributes to parse
[ "Parse", "XML", "attributes" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/widget/EmptyView.java#L173-L208
139,731
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/widget/EmptyView.java
EmptyView.setIcon
public void setIcon(Drawable drawable){ mIcon.setImageDrawable(drawable); mIcon.setVisibility(View.VISIBLE); }
java
public void setIcon(Drawable drawable){ mIcon.setImageDrawable(drawable); mIcon.setVisibility(View.VISIBLE); }
[ "public", "void", "setIcon", "(", "Drawable", "drawable", ")", "{", "mIcon", ".", "setImageDrawable", "(", "drawable", ")", ";", "mIcon", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "}" ]
Set the icon for this empty view @param drawable the drawable icon
[ "Set", "the", "icon", "for", "this", "empty", "view" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/widget/EmptyView.java#L316-L319
139,732
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/widget/EmptyView.java
EmptyView.setIconSize
public void setIconSize(int size){ mEmptyIconSize = size; int width = mEmptyIconSize == -1 ? WRAP_CONTENT : mEmptyIconSize; int height = mEmptyIconSize == -1 ? WRAP_CONTENT : mEmptyIconSize; LinearLayout.LayoutParams iconParams = new LinearLayout.LayoutParams(width, height); mIcon.setLayoutParams(iconParams); }
java
public void setIconSize(int size){ mEmptyIconSize = size; int width = mEmptyIconSize == -1 ? WRAP_CONTENT : mEmptyIconSize; int height = mEmptyIconSize == -1 ? WRAP_CONTENT : mEmptyIconSize; LinearLayout.LayoutParams iconParams = new LinearLayout.LayoutParams(width, height); mIcon.setLayoutParams(iconParams); }
[ "public", "void", "setIconSize", "(", "int", "size", ")", "{", "mEmptyIconSize", "=", "size", ";", "int", "width", "=", "mEmptyIconSize", "==", "-", "1", "?", "WRAP_CONTENT", ":", "mEmptyIconSize", ";", "int", "height", "=", "mEmptyIconSize", "==", "-", "1", "?", "WRAP_CONTENT", ":", "mEmptyIconSize", ";", "LinearLayout", ".", "LayoutParams", "iconParams", "=", "new", "LinearLayout", ".", "LayoutParams", "(", "width", ",", "height", ")", ";", "mIcon", ".", "setLayoutParams", "(", "iconParams", ")", ";", "}" ]
Set the size of the icon in the center of the view @param size the pixel size of the icon in the center
[ "Set", "the", "size", "of", "the", "icon", "in", "the", "center", "of", "the", "view" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/widget/EmptyView.java#L327-L333
139,733
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/widget/EmptyView.java
EmptyView.setActionLabel
public void setActionLabel(CharSequence label){ mEmptyActionText = label; mAction.setText(mEmptyActionText); mAction.setVisibility(TextUtils.isEmpty(mEmptyActionText) ? View.GONE : View.VISIBLE); }
java
public void setActionLabel(CharSequence label){ mEmptyActionText = label; mAction.setText(mEmptyActionText); mAction.setVisibility(TextUtils.isEmpty(mEmptyActionText) ? View.GONE : View.VISIBLE); }
[ "public", "void", "setActionLabel", "(", "CharSequence", "label", ")", "{", "mEmptyActionText", "=", "label", ";", "mAction", ".", "setText", "(", "mEmptyActionText", ")", ";", "mAction", ".", "setVisibility", "(", "TextUtils", ".", "isEmpty", "(", "mEmptyActionText", ")", "?", "View", ".", "GONE", ":", "View", ".", "VISIBLE", ")", ";", "}" ]
Set the action button label, this in-turn enables it. Pass null to disable. @param label set the action label, thus enabling it
[ "Set", "the", "action", "button", "label", "this", "in", "-", "turn", "enables", "it", ".", "Pass", "null", "to", "disable", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/widget/EmptyView.java#L449-L453
139,734
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/widget/EmptyView.java
EmptyView.setLoading
@Deprecated public void setLoading(){ mState = STATE_LOADING; mProgress.setVisibility(View.VISIBLE); mAction.setVisibility(View.GONE); mMessage.setVisibility(View.GONE); mIcon.setVisibility(View.GONE); }
java
@Deprecated public void setLoading(){ mState = STATE_LOADING; mProgress.setVisibility(View.VISIBLE); mAction.setVisibility(View.GONE); mMessage.setVisibility(View.GONE); mIcon.setVisibility(View.GONE); }
[ "@", "Deprecated", "public", "void", "setLoading", "(", ")", "{", "mState", "=", "STATE_LOADING", ";", "mProgress", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "mAction", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "mMessage", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "mIcon", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "}" ]
Set this view to loading state to show a loading indicator and hide the other parts of this view. @deprecated see {@link #setLoading(boolean)} and {@link #setState(int)}
[ "Set", "this", "view", "to", "loading", "state", "to", "show", "a", "loading", "indicator", "and", "hide", "the", "other", "parts", "of", "this", "view", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/widget/EmptyView.java#L514-L521
139,735
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/widget/EmptyView.java
EmptyView.setEmpty
@Deprecated public void setEmpty(){ mState = STATE_EMPTY; mProgress.setVisibility(View.GONE); if(mEmptyIcon != -1) mIcon.setVisibility(View.VISIBLE); if(!TextUtils.isEmpty(mEmptyMessage)) mMessage.setVisibility(View.VISIBLE); if(!TextUtils.isEmpty(mEmptyActionText)) mAction.setVisibility(View.VISIBLE); }
java
@Deprecated public void setEmpty(){ mState = STATE_EMPTY; mProgress.setVisibility(View.GONE); if(mEmptyIcon != -1) mIcon.setVisibility(View.VISIBLE); if(!TextUtils.isEmpty(mEmptyMessage)) mMessage.setVisibility(View.VISIBLE); if(!TextUtils.isEmpty(mEmptyActionText)) mAction.setVisibility(View.VISIBLE); }
[ "@", "Deprecated", "public", "void", "setEmpty", "(", ")", "{", "mState", "=", "STATE_EMPTY", ";", "mProgress", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "if", "(", "mEmptyIcon", "!=", "-", "1", ")", "mIcon", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "if", "(", "!", "TextUtils", ".", "isEmpty", "(", "mEmptyMessage", ")", ")", "mMessage", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "if", "(", "!", "TextUtils", ".", "isEmpty", "(", "mEmptyActionText", ")", ")", "mAction", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "}" ]
Set this view to it's empty state showing the icon, message, and action if configured @deprecated see {@link #setLoading(boolean)} and {@link #setState(int)}
[ "Set", "this", "view", "to", "it", "s", "empty", "state", "showing", "the", "icon", "message", "and", "action", "if", "configured" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/widget/EmptyView.java#L529-L536
139,736
52inc/android-52Kit
library-attributr/src/main/java/com/ftinc/kit/attributr/ui/widget/StickyRecyclerHeadersElevationDecoration.java
StickyRecyclerHeadersElevationDecoration.getNextView
private View getNextView(RecyclerView parent) { View firstView = parent.getChildAt(0); // draw the first visible child's header at the top of the view int firstPosition = parent.getChildPosition(firstView); View firstHeader = getHeaderView(parent, firstPosition); for (int i = 0; i < parent.getChildCount(); i++) { View child = parent.getChildAt(i); RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams(); if (getOrientation(parent) == LinearLayoutManager.VERTICAL) { if (child.getTop() - layoutParams.topMargin > firstHeader.getHeight()) { return child; } } else { if (child.getLeft() - layoutParams.leftMargin > firstHeader.getWidth()) { return child; } } } return null; }
java
private View getNextView(RecyclerView parent) { View firstView = parent.getChildAt(0); // draw the first visible child's header at the top of the view int firstPosition = parent.getChildPosition(firstView); View firstHeader = getHeaderView(parent, firstPosition); for (int i = 0; i < parent.getChildCount(); i++) { View child = parent.getChildAt(i); RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams(); if (getOrientation(parent) == LinearLayoutManager.VERTICAL) { if (child.getTop() - layoutParams.topMargin > firstHeader.getHeight()) { return child; } } else { if (child.getLeft() - layoutParams.leftMargin > firstHeader.getWidth()) { return child; } } } return null; }
[ "private", "View", "getNextView", "(", "RecyclerView", "parent", ")", "{", "View", "firstView", "=", "parent", ".", "getChildAt", "(", "0", ")", ";", "// draw the first visible child's header at the top of the view", "int", "firstPosition", "=", "parent", ".", "getChildPosition", "(", "firstView", ")", ";", "View", "firstHeader", "=", "getHeaderView", "(", "parent", ",", "firstPosition", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "parent", ".", "getChildCount", "(", ")", ";", "i", "++", ")", "{", "View", "child", "=", "parent", ".", "getChildAt", "(", "i", ")", ";", "RecyclerView", ".", "LayoutParams", "layoutParams", "=", "(", "RecyclerView", ".", "LayoutParams", ")", "child", ".", "getLayoutParams", "(", ")", ";", "if", "(", "getOrientation", "(", "parent", ")", "==", "LinearLayoutManager", ".", "VERTICAL", ")", "{", "if", "(", "child", ".", "getTop", "(", ")", "-", "layoutParams", ".", "topMargin", ">", "firstHeader", ".", "getHeight", "(", ")", ")", "{", "return", "child", ";", "}", "}", "else", "{", "if", "(", "child", ".", "getLeft", "(", ")", "-", "layoutParams", ".", "leftMargin", ">", "firstHeader", ".", "getWidth", "(", ")", ")", "{", "return", "child", ";", "}", "}", "}", "return", "null", ";", "}" ]
Returns the first item currently in the recyclerview that's not obscured by a header. @param parent @return
[ "Returns", "the", "first", "item", "currently", "in", "the", "recyclerview", "that", "s", "not", "obscured", "by", "a", "header", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library-attributr/src/main/java/com/ftinc/kit/attributr/ui/widget/StickyRecyclerHeadersElevationDecoration.java#L169-L196
139,737
52inc/android-52Kit
library-drawer/src/main/java/com/ftinc/kit/drawer/Drawer.java
Drawer.buildAndAttach
@SuppressLint("NewApi") private void buildAndAttach(){ // Disable any pending transition on the activity since we are transforming it mActivity.overridePendingTransition(0, 0); // Setup window flags if Lollipop if(BuildUtils.isLollipop()) { Window window = mActivity.getWindow(); window.addFlags(FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); } // attach layout and pane to UI hiJackDecor(); // Setup setupDrawer(); // Populate and Inflate populateNavDrawer(); }
java
@SuppressLint("NewApi") private void buildAndAttach(){ // Disable any pending transition on the activity since we are transforming it mActivity.overridePendingTransition(0, 0); // Setup window flags if Lollipop if(BuildUtils.isLollipop()) { Window window = mActivity.getWindow(); window.addFlags(FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); } // attach layout and pane to UI hiJackDecor(); // Setup setupDrawer(); // Populate and Inflate populateNavDrawer(); }
[ "@", "SuppressLint", "(", "\"NewApi\"", ")", "private", "void", "buildAndAttach", "(", ")", "{", "// Disable any pending transition on the activity since we are transforming it", "mActivity", ".", "overridePendingTransition", "(", "0", ",", "0", ")", ";", "// Setup window flags if Lollipop", "if", "(", "BuildUtils", ".", "isLollipop", "(", ")", ")", "{", "Window", "window", "=", "mActivity", ".", "getWindow", "(", ")", ";", "window", ".", "addFlags", "(", "FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS", ")", ";", "window", ".", "setStatusBarColor", "(", "Color", ".", "TRANSPARENT", ")", ";", "}", "// attach layout and pane to UI", "hiJackDecor", "(", ")", ";", "// Setup", "setupDrawer", "(", ")", ";", "// Populate and Inflate", "populateNavDrawer", "(", ")", ";", "}" ]
Build the nav drawer layout, inflate it, then attach it to the activity
[ "Build", "the", "nav", "drawer", "layout", "inflate", "it", "then", "attach", "it", "to", "the", "activity" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library-drawer/src/main/java/com/ftinc/kit/drawer/Drawer.java#L253-L274
139,738
52inc/android-52Kit
library-drawer/src/main/java/com/ftinc/kit/drawer/Drawer.java
Drawer.setupDrawer
private void setupDrawer(){ // Setup drawer background color if set int backgroundColor = UIUtils.getColorAttr(mActivity, R.attr.drawerBackground); if(backgroundColor > 0){ mDrawerPane.setBackgroundColor(backgroundColor); } // Set the drawer layout statusbar color int statusBarColor = mConfig.getStatusBarColor(mActivity); if(statusBarColor != -1) mDrawerLayout.setStatusBarBackgroundColor(statusBarColor); // Populate Header View populateHeader(); // Populate Footer View populateFooter(); // Configure the scrim inset pane view final int headerHeight = mActivity.getResources().getDimensionPixelSize( R.dimen.navdrawer_chosen_account_height); mDrawerPane.setOnInsetsCallback(new OnInsetsCallback() { @Override public void onInsetsChanged(Rect insets) { if (mHeaderView != null) { mConfig.onInsetsChanged(mHeaderView, insets); ViewGroup.LayoutParams lp2 = mDrawerHeaderFrame.getLayoutParams(); lp2.height = headerHeight + insets.top; mDrawerHeaderFrame.setLayoutParams(lp2); }else{ ViewGroup.LayoutParams lp2 = mDrawerHeaderFrame.getLayoutParams(); lp2.height = insets.top; mDrawerHeaderFrame.setLayoutParams(lp2); } } }); // Setup the drawer toggle if(mToolbar != null){ mDrawerToggle = new ActionBarDrawerToggle(mActivity, mDrawerLayout, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close){ @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); if(mCallbacks != null) mCallbacks.onDrawerClosed(drawerView); } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); if(mCallbacks != null) mCallbacks.onDrawerOpened(drawerView); } @Override public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, mConfig.shouldAnimateIndicator() ? slideOffset : 0); if(mCallbacks != null) mCallbacks.onDrawerSlide(drawerView, slideOffset); } }; // Defer code dependent on restoration of previous instance state. mDrawerLayout.post(new Runnable() { @Override public void run() { mDrawerToggle.syncState(); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); } // Setup the drawer shadow mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); }
java
private void setupDrawer(){ // Setup drawer background color if set int backgroundColor = UIUtils.getColorAttr(mActivity, R.attr.drawerBackground); if(backgroundColor > 0){ mDrawerPane.setBackgroundColor(backgroundColor); } // Set the drawer layout statusbar color int statusBarColor = mConfig.getStatusBarColor(mActivity); if(statusBarColor != -1) mDrawerLayout.setStatusBarBackgroundColor(statusBarColor); // Populate Header View populateHeader(); // Populate Footer View populateFooter(); // Configure the scrim inset pane view final int headerHeight = mActivity.getResources().getDimensionPixelSize( R.dimen.navdrawer_chosen_account_height); mDrawerPane.setOnInsetsCallback(new OnInsetsCallback() { @Override public void onInsetsChanged(Rect insets) { if (mHeaderView != null) { mConfig.onInsetsChanged(mHeaderView, insets); ViewGroup.LayoutParams lp2 = mDrawerHeaderFrame.getLayoutParams(); lp2.height = headerHeight + insets.top; mDrawerHeaderFrame.setLayoutParams(lp2); }else{ ViewGroup.LayoutParams lp2 = mDrawerHeaderFrame.getLayoutParams(); lp2.height = insets.top; mDrawerHeaderFrame.setLayoutParams(lp2); } } }); // Setup the drawer toggle if(mToolbar != null){ mDrawerToggle = new ActionBarDrawerToggle(mActivity, mDrawerLayout, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close){ @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); if(mCallbacks != null) mCallbacks.onDrawerClosed(drawerView); } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); if(mCallbacks != null) mCallbacks.onDrawerOpened(drawerView); } @Override public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, mConfig.shouldAnimateIndicator() ? slideOffset : 0); if(mCallbacks != null) mCallbacks.onDrawerSlide(drawerView, slideOffset); } }; // Defer code dependent on restoration of previous instance state. mDrawerLayout.post(new Runnable() { @Override public void run() { mDrawerToggle.syncState(); } }); mDrawerLayout.setDrawerListener(mDrawerToggle); } // Setup the drawer shadow mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); }
[ "private", "void", "setupDrawer", "(", ")", "{", "// Setup drawer background color if set", "int", "backgroundColor", "=", "UIUtils", ".", "getColorAttr", "(", "mActivity", ",", "R", ".", "attr", ".", "drawerBackground", ")", ";", "if", "(", "backgroundColor", ">", "0", ")", "{", "mDrawerPane", ".", "setBackgroundColor", "(", "backgroundColor", ")", ";", "}", "// Set the drawer layout statusbar color", "int", "statusBarColor", "=", "mConfig", ".", "getStatusBarColor", "(", "mActivity", ")", ";", "if", "(", "statusBarColor", "!=", "-", "1", ")", "mDrawerLayout", ".", "setStatusBarBackgroundColor", "(", "statusBarColor", ")", ";", "// Populate Header View", "populateHeader", "(", ")", ";", "// Populate Footer View", "populateFooter", "(", ")", ";", "// Configure the scrim inset pane view", "final", "int", "headerHeight", "=", "mActivity", ".", "getResources", "(", ")", ".", "getDimensionPixelSize", "(", "R", ".", "dimen", ".", "navdrawer_chosen_account_height", ")", ";", "mDrawerPane", ".", "setOnInsetsCallback", "(", "new", "OnInsetsCallback", "(", ")", "{", "@", "Override", "public", "void", "onInsetsChanged", "(", "Rect", "insets", ")", "{", "if", "(", "mHeaderView", "!=", "null", ")", "{", "mConfig", ".", "onInsetsChanged", "(", "mHeaderView", ",", "insets", ")", ";", "ViewGroup", ".", "LayoutParams", "lp2", "=", "mDrawerHeaderFrame", ".", "getLayoutParams", "(", ")", ";", "lp2", ".", "height", "=", "headerHeight", "+", "insets", ".", "top", ";", "mDrawerHeaderFrame", ".", "setLayoutParams", "(", "lp2", ")", ";", "}", "else", "{", "ViewGroup", ".", "LayoutParams", "lp2", "=", "mDrawerHeaderFrame", ".", "getLayoutParams", "(", ")", ";", "lp2", ".", "height", "=", "insets", ".", "top", ";", "mDrawerHeaderFrame", ".", "setLayoutParams", "(", "lp2", ")", ";", "}", "}", "}", ")", ";", "// Setup the drawer toggle", "if", "(", "mToolbar", "!=", "null", ")", "{", "mDrawerToggle", "=", "new", "ActionBarDrawerToggle", "(", "mActivity", ",", "mDrawerLayout", ",", "mToolbar", ",", "R", ".", "string", ".", "navigation_drawer_open", ",", "R", ".", "string", ".", "navigation_drawer_close", ")", "{", "@", "Override", "public", "void", "onDrawerClosed", "(", "View", "drawerView", ")", "{", "super", ".", "onDrawerClosed", "(", "drawerView", ")", ";", "if", "(", "mCallbacks", "!=", "null", ")", "mCallbacks", ".", "onDrawerClosed", "(", "drawerView", ")", ";", "}", "@", "Override", "public", "void", "onDrawerOpened", "(", "View", "drawerView", ")", "{", "super", ".", "onDrawerOpened", "(", "drawerView", ")", ";", "if", "(", "mCallbacks", "!=", "null", ")", "mCallbacks", ".", "onDrawerOpened", "(", "drawerView", ")", ";", "}", "@", "Override", "public", "void", "onDrawerSlide", "(", "View", "drawerView", ",", "float", "slideOffset", ")", "{", "super", ".", "onDrawerSlide", "(", "drawerView", ",", "mConfig", ".", "shouldAnimateIndicator", "(", ")", "?", "slideOffset", ":", "0", ")", ";", "if", "(", "mCallbacks", "!=", "null", ")", "mCallbacks", ".", "onDrawerSlide", "(", "drawerView", ",", "slideOffset", ")", ";", "}", "}", ";", "// Defer code dependent on restoration of previous instance state.", "mDrawerLayout", ".", "post", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "mDrawerToggle", ".", "syncState", "(", ")", ";", "}", "}", ")", ";", "mDrawerLayout", ".", "setDrawerListener", "(", "mDrawerToggle", ")", ";", "}", "// Setup the drawer shadow", "mDrawerLayout", ".", "setDrawerShadow", "(", "R", ".", "drawable", ".", "drawer_shadow", ",", "GravityCompat", ".", "START", ")", ";", "}" ]
Setup the navigation drawer layout and whatnot
[ "Setup", "the", "navigation", "drawer", "layout", "and", "whatnot" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library-drawer/src/main/java/com/ftinc/kit/drawer/Drawer.java#L302-L384
139,739
52inc/android-52Kit
library-drawer/src/main/java/com/ftinc/kit/drawer/Drawer.java
Drawer.createNavDrawerItems
private void createNavDrawerItems(){ if (mDrawerItemsListContainer == null) { return; } mNavDrawerItemViews.clear(); mDrawerItemsListContainer.removeAllViews(); for (DrawerItem item: mDrawerItems) { item.setSelected(item.getId() == mSelectedItem); View view = item.onCreateView(mActivity.getLayoutInflater(), mDrawerItemsListContainer, mConfig.getItemHighlightColor(mActivity)); if(!(item instanceof SeperatorDrawerItem)){ view.setId(item.getId()); mNavDrawerItemViews.put(item.getId(), view); mNavDrawerItems.put(item.getId(), item); // Set the view's click listener if(!(item instanceof SwitchDrawerItem)) { view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onNavDrawerItemClicked(v.getId()); } }); } } mDrawerItemsListContainer.addView(view); } }
java
private void createNavDrawerItems(){ if (mDrawerItemsListContainer == null) { return; } mNavDrawerItemViews.clear(); mDrawerItemsListContainer.removeAllViews(); for (DrawerItem item: mDrawerItems) { item.setSelected(item.getId() == mSelectedItem); View view = item.onCreateView(mActivity.getLayoutInflater(), mDrawerItemsListContainer, mConfig.getItemHighlightColor(mActivity)); if(!(item instanceof SeperatorDrawerItem)){ view.setId(item.getId()); mNavDrawerItemViews.put(item.getId(), view); mNavDrawerItems.put(item.getId(), item); // Set the view's click listener if(!(item instanceof SwitchDrawerItem)) { view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onNavDrawerItemClicked(v.getId()); } }); } } mDrawerItemsListContainer.addView(view); } }
[ "private", "void", "createNavDrawerItems", "(", ")", "{", "if", "(", "mDrawerItemsListContainer", "==", "null", ")", "{", "return", ";", "}", "mNavDrawerItemViews", ".", "clear", "(", ")", ";", "mDrawerItemsListContainer", ".", "removeAllViews", "(", ")", ";", "for", "(", "DrawerItem", "item", ":", "mDrawerItems", ")", "{", "item", ".", "setSelected", "(", "item", ".", "getId", "(", ")", "==", "mSelectedItem", ")", ";", "View", "view", "=", "item", ".", "onCreateView", "(", "mActivity", ".", "getLayoutInflater", "(", ")", ",", "mDrawerItemsListContainer", ",", "mConfig", ".", "getItemHighlightColor", "(", "mActivity", ")", ")", ";", "if", "(", "!", "(", "item", "instanceof", "SeperatorDrawerItem", ")", ")", "{", "view", ".", "setId", "(", "item", ".", "getId", "(", ")", ")", ";", "mNavDrawerItemViews", ".", "put", "(", "item", ".", "getId", "(", ")", ",", "view", ")", ";", "mNavDrawerItems", ".", "put", "(", "item", ".", "getId", "(", ")", ",", "item", ")", ";", "// Set the view's click listener", "if", "(", "!", "(", "item", "instanceof", "SwitchDrawerItem", ")", ")", "{", "view", ".", "setOnClickListener", "(", "new", "View", ".", "OnClickListener", "(", ")", "{", "@", "Override", "public", "void", "onClick", "(", "View", "v", ")", "{", "onNavDrawerItemClicked", "(", "v", ".", "getId", "(", ")", ")", ";", "}", "}", ")", ";", "}", "}", "mDrawerItemsListContainer", ".", "addView", "(", "view", ")", ";", "}", "}" ]
Populate the nav drawer items into the view
[ "Populate", "the", "nav", "drawer", "items", "into", "the", "view" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library-drawer/src/main/java/com/ftinc/kit/drawer/Drawer.java#L435-L465
139,740
52inc/android-52Kit
library-drawer/src/main/java/com/ftinc/kit/drawer/Drawer.java
Drawer.onNavDrawerItemClicked
private void onNavDrawerItemClicked(final int itemId) { if (itemId == mSelectedItem) { mDrawerLayout.closeDrawer(GravityCompat.START); return; } if (isSpecialItem(itemId)) { goToNavDrawerItem(itemId); } else { // launch the target Activity after a short delay, to allow the close animation to play mHandler.postDelayed(new Runnable() { @Override public void run() { goToNavDrawerItem(itemId); } }, mConfig.getLaunchDelay()); // change the active item on the list so the user can see the item changed setSelectedNavDrawerItem(itemId); // fade out the main content // if (mMainContent != null && mConfig.getFadeOutDuration() != -1) { // mMainContent.animate().alpha(0).setDuration(mConfig.getFadeOutDuration()); // } } mDrawerLayout.closeDrawer(GravityCompat.START); }
java
private void onNavDrawerItemClicked(final int itemId) { if (itemId == mSelectedItem) { mDrawerLayout.closeDrawer(GravityCompat.START); return; } if (isSpecialItem(itemId)) { goToNavDrawerItem(itemId); } else { // launch the target Activity after a short delay, to allow the close animation to play mHandler.postDelayed(new Runnable() { @Override public void run() { goToNavDrawerItem(itemId); } }, mConfig.getLaunchDelay()); // change the active item on the list so the user can see the item changed setSelectedNavDrawerItem(itemId); // fade out the main content // if (mMainContent != null && mConfig.getFadeOutDuration() != -1) { // mMainContent.animate().alpha(0).setDuration(mConfig.getFadeOutDuration()); // } } mDrawerLayout.closeDrawer(GravityCompat.START); }
[ "private", "void", "onNavDrawerItemClicked", "(", "final", "int", "itemId", ")", "{", "if", "(", "itemId", "==", "mSelectedItem", ")", "{", "mDrawerLayout", ".", "closeDrawer", "(", "GravityCompat", ".", "START", ")", ";", "return", ";", "}", "if", "(", "isSpecialItem", "(", "itemId", ")", ")", "{", "goToNavDrawerItem", "(", "itemId", ")", ";", "}", "else", "{", "// launch the target Activity after a short delay, to allow the close animation to play", "mHandler", ".", "postDelayed", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "goToNavDrawerItem", "(", "itemId", ")", ";", "}", "}", ",", "mConfig", ".", "getLaunchDelay", "(", ")", ")", ";", "// change the active item on the list so the user can see the item changed", "setSelectedNavDrawerItem", "(", "itemId", ")", ";", "// fade out the main content", "// if (mMainContent != null && mConfig.getFadeOutDuration() != -1) {", "// mMainContent.animate().alpha(0).setDuration(mConfig.getFadeOutDuration());", "// }", "}", "mDrawerLayout", ".", "closeDrawer", "(", "GravityCompat", ".", "START", ")", ";", "}" ]
Call when a nav drawer item is clicked @param itemId the id of the item clicked
[ "Call", "when", "a", "nav", "drawer", "item", "is", "clicked" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library-drawer/src/main/java/com/ftinc/kit/drawer/Drawer.java#L482-L509
139,741
52inc/android-52Kit
library-drawer/src/main/java/com/ftinc/kit/drawer/Drawer.java
Drawer.formatNavDrawerItem
private void formatNavDrawerItem(DrawerItem item, boolean selected) { if (item instanceof SeperatorDrawerItem || item instanceof SwitchDrawerItem) { // not applicable return; } // Get the associated view View view = mNavDrawerItemViews.get(item.getId()); ImageView iconView = (ImageView) view.findViewById(R.id.icon); TextView titleView = (TextView) view.findViewById(R.id.title); // configure its appearance according to whether or not it's selected titleView.setTextColor(selected ? mConfig.getItemHighlightColor(mActivity) : UIUtils.getColorAttr(mActivity, android.R.attr.textColorPrimary)); iconView.setColorFilter(selected ? mConfig.getItemHighlightColor(mActivity) : getResources().getColor(R.color.navdrawer_icon_tint), PorterDuff.Mode.SRC_ATOP); }
java
private void formatNavDrawerItem(DrawerItem item, boolean selected) { if (item instanceof SeperatorDrawerItem || item instanceof SwitchDrawerItem) { // not applicable return; } // Get the associated view View view = mNavDrawerItemViews.get(item.getId()); ImageView iconView = (ImageView) view.findViewById(R.id.icon); TextView titleView = (TextView) view.findViewById(R.id.title); // configure its appearance according to whether or not it's selected titleView.setTextColor(selected ? mConfig.getItemHighlightColor(mActivity) : UIUtils.getColorAttr(mActivity, android.R.attr.textColorPrimary)); iconView.setColorFilter(selected ? mConfig.getItemHighlightColor(mActivity) : getResources().getColor(R.color.navdrawer_icon_tint), PorterDuff.Mode.SRC_ATOP); }
[ "private", "void", "formatNavDrawerItem", "(", "DrawerItem", "item", ",", "boolean", "selected", ")", "{", "if", "(", "item", "instanceof", "SeperatorDrawerItem", "||", "item", "instanceof", "SwitchDrawerItem", ")", "{", "// not applicable", "return", ";", "}", "// Get the associated view", "View", "view", "=", "mNavDrawerItemViews", ".", "get", "(", "item", ".", "getId", "(", ")", ")", ";", "ImageView", "iconView", "=", "(", "ImageView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "icon", ")", ";", "TextView", "titleView", "=", "(", "TextView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "title", ")", ";", "// configure its appearance according to whether or not it's selected", "titleView", ".", "setTextColor", "(", "selected", "?", "mConfig", ".", "getItemHighlightColor", "(", "mActivity", ")", ":", "UIUtils", ".", "getColorAttr", "(", "mActivity", ",", "android", ".", "R", ".", "attr", ".", "textColorPrimary", ")", ")", ";", "iconView", ".", "setColorFilter", "(", "selected", "?", "mConfig", ".", "getItemHighlightColor", "(", "mActivity", ")", ":", "getResources", "(", ")", ".", "getColor", "(", "R", ".", "color", ".", "navdrawer_icon_tint", ")", ",", "PorterDuff", ".", "Mode", ".", "SRC_ATOP", ")", ";", "}" ]
Format a nav drawer item based on current selected states @param item @param selected
[ "Format", "a", "nav", "drawer", "item", "based", "on", "current", "selected", "states" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library-drawer/src/main/java/com/ftinc/kit/drawer/Drawer.java#L536-L556
139,742
52inc/android-52Kit
library-drawer/src/main/java/com/ftinc/kit/drawer/Drawer.java
Drawer.inflateDrawerLayout
private DrawerLayout inflateDrawerLayout(ViewGroup parent){ DrawerLayout drawer = (DrawerLayout) mActivity.getLayoutInflater() .inflate(R.layout.material_drawer, parent, false); // Find the associated views mDrawerPane = ButterKnife.findById(drawer, R.id.navdrawer); mDrawerContentFrame = ButterKnife.findById(drawer, R.id.drawer_content_frame); mDrawerHeaderFrame = ButterKnife.findById(mDrawerPane, R.id.header_container); mDrawerFooterFrame = ButterKnife.findById(mDrawerPane, R.id.footer); mDrawerItemsListContainer = ButterKnife.findById(mDrawerPane, R.id.navdrawer_items_list); // Return the drawer return drawer; }
java
private DrawerLayout inflateDrawerLayout(ViewGroup parent){ DrawerLayout drawer = (DrawerLayout) mActivity.getLayoutInflater() .inflate(R.layout.material_drawer, parent, false); // Find the associated views mDrawerPane = ButterKnife.findById(drawer, R.id.navdrawer); mDrawerContentFrame = ButterKnife.findById(drawer, R.id.drawer_content_frame); mDrawerHeaderFrame = ButterKnife.findById(mDrawerPane, R.id.header_container); mDrawerFooterFrame = ButterKnife.findById(mDrawerPane, R.id.footer); mDrawerItemsListContainer = ButterKnife.findById(mDrawerPane, R.id.navdrawer_items_list); // Return the drawer return drawer; }
[ "private", "DrawerLayout", "inflateDrawerLayout", "(", "ViewGroup", "parent", ")", "{", "DrawerLayout", "drawer", "=", "(", "DrawerLayout", ")", "mActivity", ".", "getLayoutInflater", "(", ")", ".", "inflate", "(", "R", ".", "layout", ".", "material_drawer", ",", "parent", ",", "false", ")", ";", "// Find the associated views", "mDrawerPane", "=", "ButterKnife", ".", "findById", "(", "drawer", ",", "R", ".", "id", ".", "navdrawer", ")", ";", "mDrawerContentFrame", "=", "ButterKnife", ".", "findById", "(", "drawer", ",", "R", ".", "id", ".", "drawer_content_frame", ")", ";", "mDrawerHeaderFrame", "=", "ButterKnife", ".", "findById", "(", "mDrawerPane", ",", "R", ".", "id", ".", "header_container", ")", ";", "mDrawerFooterFrame", "=", "ButterKnife", ".", "findById", "(", "mDrawerPane", ",", "R", ".", "id", ".", "footer", ")", ";", "mDrawerItemsListContainer", "=", "ButterKnife", ".", "findById", "(", "mDrawerPane", ",", "R", ".", "id", ".", "navdrawer_items_list", ")", ";", "// Return the drawer", "return", "drawer", ";", "}" ]
Build the root drawer layout @return the root drawer layout
[ "Build", "the", "root", "drawer", "layout" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library-drawer/src/main/java/com/ftinc/kit/drawer/Drawer.java#L569-L582
139,743
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/widget/AspectRatioImageView.java
AspectRatioImageView.onMeasure
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { Drawable drawable = getDrawable(); if (getDrawable() != null) { if (ratioType == RATIO_WIDTH) { int width = MeasureSpec.getSize(widthMeasureSpec); int height = Math.round(width * (((float) drawable.getIntrinsicHeight()) / ((float) drawable.getIntrinsicWidth()))); setMeasuredDimension(width, height); } else if (ratioType == RATIO_HEIGHT) { int height = MeasureSpec.getSize(heightMeasureSpec); int width = Math.round(height * ((float) drawable.getIntrinsicWidth()) / ((float) drawable.getIntrinsicHeight())); setMeasuredDimension(width, height); } } else { super.onMeasure(widthMeasureSpec, heightMeasureSpec); } }
java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { Drawable drawable = getDrawable(); if (getDrawable() != null) { if (ratioType == RATIO_WIDTH) { int width = MeasureSpec.getSize(widthMeasureSpec); int height = Math.round(width * (((float) drawable.getIntrinsicHeight()) / ((float) drawable.getIntrinsicWidth()))); setMeasuredDimension(width, height); } else if (ratioType == RATIO_HEIGHT) { int height = MeasureSpec.getSize(heightMeasureSpec); int width = Math.round(height * ((float) drawable.getIntrinsicWidth()) / ((float) drawable.getIntrinsicHeight())); setMeasuredDimension(width, height); } } else { super.onMeasure(widthMeasureSpec, heightMeasureSpec); } }
[ "@", "Override", "protected", "void", "onMeasure", "(", "int", "widthMeasureSpec", ",", "int", "heightMeasureSpec", ")", "{", "Drawable", "drawable", "=", "getDrawable", "(", ")", ";", "if", "(", "getDrawable", "(", ")", "!=", "null", ")", "{", "if", "(", "ratioType", "==", "RATIO_WIDTH", ")", "{", "int", "width", "=", "MeasureSpec", ".", "getSize", "(", "widthMeasureSpec", ")", ";", "int", "height", "=", "Math", ".", "round", "(", "width", "*", "(", "(", "(", "float", ")", "drawable", ".", "getIntrinsicHeight", "(", ")", ")", "/", "(", "(", "float", ")", "drawable", ".", "getIntrinsicWidth", "(", ")", ")", ")", ")", ";", "setMeasuredDimension", "(", "width", ",", "height", ")", ";", "}", "else", "if", "(", "ratioType", "==", "RATIO_HEIGHT", ")", "{", "int", "height", "=", "MeasureSpec", ".", "getSize", "(", "heightMeasureSpec", ")", ";", "int", "width", "=", "Math", ".", "round", "(", "height", "*", "(", "(", "float", ")", "drawable", ".", "getIntrinsicWidth", "(", ")", ")", "/", "(", "(", "float", ")", "drawable", ".", "getIntrinsicHeight", "(", ")", ")", ")", ";", "setMeasuredDimension", "(", "width", ",", "height", ")", ";", "}", "}", "else", "{", "super", ".", "onMeasure", "(", "widthMeasureSpec", ",", "heightMeasureSpec", ")", ";", "}", "}" ]
Maintain Image Aspect Ratio no matter the size
[ "Maintain", "Image", "Aspect", "Ratio", "no", "matter", "the", "size" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/widget/AspectRatioImageView.java#L72-L88
139,744
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/UIUtils.java
UIUtils.getStatusBarHeight
public static int getStatusBarHeight(Context ctx) { int result = 0; int resourceId = ctx.getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { result = ctx.getResources().getDimensionPixelSize(resourceId); } return result; }
java
public static int getStatusBarHeight(Context ctx) { int result = 0; int resourceId = ctx.getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { result = ctx.getResources().getDimensionPixelSize(resourceId); } return result; }
[ "public", "static", "int", "getStatusBarHeight", "(", "Context", "ctx", ")", "{", "int", "result", "=", "0", ";", "int", "resourceId", "=", "ctx", ".", "getResources", "(", ")", ".", "getIdentifier", "(", "\"status_bar_height\"", ",", "\"dimen\"", ",", "\"android\"", ")", ";", "if", "(", "resourceId", ">", "0", ")", "{", "result", "=", "ctx", ".", "getResources", "(", ")", ".", "getDimensionPixelSize", "(", "resourceId", ")", ";", "}", "return", "result", ";", "}" ]
Get the status bar height
[ "Get", "the", "status", "bar", "height" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/UIUtils.java#L166-L173
139,745
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java
BetterRecyclerAdapter.onItemClick
protected void onItemClick(View view, int position){ if(itemClickListener != null) itemClickListener.onItemClick(view, getItem(position), position); }
java
protected void onItemClick(View view, int position){ if(itemClickListener != null) itemClickListener.onItemClick(view, getItem(position), position); }
[ "protected", "void", "onItemClick", "(", "View", "view", ",", "int", "position", ")", "{", "if", "(", "itemClickListener", "!=", "null", ")", "itemClickListener", ".", "onItemClick", "(", "view", ",", "getItem", "(", "position", ")", ",", "position", ")", ";", "}" ]
Call this to trigger the user set item click listener @param view the view that was clicked @param position the position that was clicked
[ "Call", "this", "to", "trigger", "the", "user", "set", "item", "click", "listener" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java#L75-L77
139,746
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java
BetterRecyclerAdapter.onItemLongClick
protected void onItemLongClick(View view, int position){ if(itemLongClickListener != null) itemLongClickListener.onItemLongClick(view, getItem(position), position); }
java
protected void onItemLongClick(View view, int position){ if(itemLongClickListener != null) itemLongClickListener.onItemLongClick(view, getItem(position), position); }
[ "protected", "void", "onItemLongClick", "(", "View", "view", ",", "int", "position", ")", "{", "if", "(", "itemLongClickListener", "!=", "null", ")", "itemLongClickListener", ".", "onItemLongClick", "(", "view", ",", "getItem", "(", "position", ")", ",", "position", ")", ";", "}" ]
Call this to trigger the user set item long click lisetner @param view the view that was clicked @param position the position that was clicked
[ "Call", "this", "to", "trigger", "the", "user", "set", "item", "long", "click", "lisetner" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java#L84-L86
139,747
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java
BetterRecyclerAdapter.setEmptyView
public void setEmptyView(View emptyView){ if(this.emptyView != null){ unregisterAdapterDataObserver(mEmptyObserver); } this.emptyView = emptyView; registerAdapterDataObserver(mEmptyObserver); }
java
public void setEmptyView(View emptyView){ if(this.emptyView != null){ unregisterAdapterDataObserver(mEmptyObserver); } this.emptyView = emptyView; registerAdapterDataObserver(mEmptyObserver); }
[ "public", "void", "setEmptyView", "(", "View", "emptyView", ")", "{", "if", "(", "this", ".", "emptyView", "!=", "null", ")", "{", "unregisterAdapterDataObserver", "(", "mEmptyObserver", ")", ";", "}", "this", ".", "emptyView", "=", "emptyView", ";", "registerAdapterDataObserver", "(", "mEmptyObserver", ")", ";", "}" ]
Set the empty view to be used so that @param emptyView
[ "Set", "the", "empty", "view", "to", "be", "used", "so", "that" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java#L130-L136
139,748
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java
BetterRecyclerAdapter.checkIfEmpty
private void checkIfEmpty(){ if(emptyView != null){ emptyView.setVisibility(getItemCount() > 0 ? View.GONE : View.VISIBLE); } }
java
private void checkIfEmpty(){ if(emptyView != null){ emptyView.setVisibility(getItemCount() > 0 ? View.GONE : View.VISIBLE); } }
[ "private", "void", "checkIfEmpty", "(", ")", "{", "if", "(", "emptyView", "!=", "null", ")", "{", "emptyView", ".", "setVisibility", "(", "getItemCount", "(", ")", ">", "0", "?", "View", ".", "GONE", ":", "View", ".", "VISIBLE", ")", ";", "}", "}" ]
Check if we should show the empty view
[ "Check", "if", "we", "should", "show", "the", "empty", "view" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java#L141-L145
139,749
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java
BetterRecyclerAdapter.addAll
public void addAll(Collection<? extends M> collection) { if (collection != null) { items.addAll(collection); applyFilter(); } }
java
public void addAll(Collection<? extends M> collection) { if (collection != null) { items.addAll(collection); applyFilter(); } }
[ "public", "void", "addAll", "(", "Collection", "<", "?", "extends", "M", ">", "collection", ")", "{", "if", "(", "collection", "!=", "null", ")", "{", "items", ".", "addAll", "(", "collection", ")", ";", "applyFilter", "(", ")", ";", "}", "}" ]
Add a collection of objects to this adapter @param collection the collection of objects to add
[ "Add", "a", "collection", "of", "objects", "to", "this", "adapter" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java#L203-L208
139,750
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java
BetterRecyclerAdapter.remove
public M remove(int index){ M item = items.remove(index); applyFilter(); return item; }
java
public M remove(int index){ M item = items.remove(index); applyFilter(); return item; }
[ "public", "M", "remove", "(", "int", "index", ")", "{", "M", "item", "=", "items", ".", "remove", "(", "index", ")", ";", "applyFilter", "(", ")", ";", "return", "item", ";", "}" ]
Remove an item at the given index @param index the index of the item to remove @return the removed item
[ "Remove", "an", "item", "at", "the", "given", "index" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java#L246-L250
139,751
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java
BetterRecyclerAdapter.moveItem
public void moveItem(int start, int end){ M startItem = filteredItems.get(start); M endItem = filteredItems.get(end); int realStart = items.indexOf(startItem); int realEnd = items.indexOf(endItem); Collections.swap(items, realStart, realEnd); applyFilter(); onItemMoved(startItem, realStart, realEnd); notifyItemMoved(realStart, realEnd); }
java
public void moveItem(int start, int end){ M startItem = filteredItems.get(start); M endItem = filteredItems.get(end); int realStart = items.indexOf(startItem); int realEnd = items.indexOf(endItem); Collections.swap(items, realStart, realEnd); applyFilter(); onItemMoved(startItem, realStart, realEnd); notifyItemMoved(realStart, realEnd); }
[ "public", "void", "moveItem", "(", "int", "start", ",", "int", "end", ")", "{", "M", "startItem", "=", "filteredItems", ".", "get", "(", "start", ")", ";", "M", "endItem", "=", "filteredItems", ".", "get", "(", "end", ")", ";", "int", "realStart", "=", "items", ".", "indexOf", "(", "startItem", ")", ";", "int", "realEnd", "=", "items", ".", "indexOf", "(", "endItem", ")", ";", "Collections", ".", "swap", "(", "items", ",", "realStart", ",", "realEnd", ")", ";", "applyFilter", "(", ")", ";", "onItemMoved", "(", "startItem", ",", "realStart", ",", "realEnd", ")", ";", "notifyItemMoved", "(", "realStart", ",", "realEnd", ")", ";", "}" ]
Move an item around in the underlying array @param start the item to move @param end the position to move to
[ "Move", "an", "item", "around", "in", "the", "underlying", "array" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java#L258-L270
139,752
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java
BetterRecyclerAdapter.applyFilter
private void applyFilter(){ filteredItems.clear(); Filter<M> filter = getFilter(); if(filter == null){ filteredItems.addAll(items); }else{ for (int i = 0; i < items.size(); i++) { M item = items.get(i); if(filter.filter(item, query)){ filteredItems.add(item); } } } onFiltered(); }
java
private void applyFilter(){ filteredItems.clear(); Filter<M> filter = getFilter(); if(filter == null){ filteredItems.addAll(items); }else{ for (int i = 0; i < items.size(); i++) { M item = items.get(i); if(filter.filter(item, query)){ filteredItems.add(item); } } } onFiltered(); }
[ "private", "void", "applyFilter", "(", ")", "{", "filteredItems", ".", "clear", "(", ")", ";", "Filter", "<", "M", ">", "filter", "=", "getFilter", "(", ")", ";", "if", "(", "filter", "==", "null", ")", "{", "filteredItems", ".", "addAll", "(", "items", ")", ";", "}", "else", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "items", ".", "size", "(", ")", ";", "i", "++", ")", "{", "M", "item", "=", "items", ".", "get", "(", "i", ")", ";", "if", "(", "filter", ".", "filter", "(", "item", ",", "query", ")", ")", "{", "filteredItems", ".", "add", "(", "item", ")", ";", "}", "}", "}", "onFiltered", "(", ")", ";", "}" ]
Apply the filter, if possible, to the adapter to update content
[ "Apply", "the", "filter", "if", "possible", "to", "the", "adapter", "to", "update", "content" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java#L353-L369
139,753
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java
BetterRecyclerAdapter.onBindViewHolder
@Override public void onBindViewHolder(final VH vh, final int i) { if(itemClickListener != null){ vh.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int position = vh.getAdapterPosition(); if (position != RecyclerView.NO_POSITION) { itemClickListener.onItemClick(v, getItem(position), position); } } }); } if(itemLongClickListener != null){ vh.itemView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { int position = vh.getAdapterPosition(); if (position != RecyclerView.NO_POSITION) { return itemLongClickListener.onItemLongClick(v, getItem(position), position); } return false; } }); } }
java
@Override public void onBindViewHolder(final VH vh, final int i) { if(itemClickListener != null){ vh.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int position = vh.getAdapterPosition(); if (position != RecyclerView.NO_POSITION) { itemClickListener.onItemClick(v, getItem(position), position); } } }); } if(itemLongClickListener != null){ vh.itemView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { int position = vh.getAdapterPosition(); if (position != RecyclerView.NO_POSITION) { return itemLongClickListener.onItemLongClick(v, getItem(position), position); } return false; } }); } }
[ "@", "Override", "public", "void", "onBindViewHolder", "(", "final", "VH", "vh", ",", "final", "int", "i", ")", "{", "if", "(", "itemClickListener", "!=", "null", ")", "{", "vh", ".", "itemView", ".", "setOnClickListener", "(", "new", "View", ".", "OnClickListener", "(", ")", "{", "@", "Override", "public", "void", "onClick", "(", "View", "v", ")", "{", "int", "position", "=", "vh", ".", "getAdapterPosition", "(", ")", ";", "if", "(", "position", "!=", "RecyclerView", ".", "NO_POSITION", ")", "{", "itemClickListener", ".", "onItemClick", "(", "v", ",", "getItem", "(", "position", ")", ",", "position", ")", ";", "}", "}", "}", ")", ";", "}", "if", "(", "itemLongClickListener", "!=", "null", ")", "{", "vh", ".", "itemView", ".", "setOnLongClickListener", "(", "new", "View", ".", "OnLongClickListener", "(", ")", "{", "@", "Override", "public", "boolean", "onLongClick", "(", "View", "v", ")", "{", "int", "position", "=", "vh", ".", "getAdapterPosition", "(", ")", ";", "if", "(", "position", "!=", "RecyclerView", ".", "NO_POSITION", ")", "{", "return", "itemLongClickListener", ".", "onItemLongClick", "(", "v", ",", "getItem", "(", "position", ")", ",", "position", ")", ";", "}", "return", "false", ";", "}", "}", ")", ";", "}", "}" ]
Intercept the bind View holder method to wire up the item click listener only if the listener is set by the user CAVEAT: Be sure that you still override this method and call it's super (or don't if you want to override this functionality and use the {@link #onItemClick(android.view.View, int)} method) @param vh the view holder @param i the position being bound
[ "Intercept", "the", "bind", "View", "holder", "method", "to", "wire", "up", "the", "item", "click", "listener", "only", "if", "the", "listener", "is", "set", "by", "the", "user" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java#L398-L424
139,754
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java
BetterRecyclerAdapter.getItemId
@Override public long getItemId(int position) { if(position > RecyclerView.NO_ID && position < getItemCount()) { M item = getItem(position); if (item != null) return item.hashCode(); return position; } return RecyclerView.NO_ID; }
java
@Override public long getItemId(int position) { if(position > RecyclerView.NO_ID && position < getItemCount()) { M item = getItem(position); if (item != null) return item.hashCode(); return position; } return RecyclerView.NO_ID; }
[ "@", "Override", "public", "long", "getItemId", "(", "int", "position", ")", "{", "if", "(", "position", ">", "RecyclerView", ".", "NO_ID", "&&", "position", "<", "getItemCount", "(", ")", ")", "{", "M", "item", "=", "getItem", "(", "position", ")", ";", "if", "(", "item", "!=", "null", ")", "return", "item", ".", "hashCode", "(", ")", ";", "return", "position", ";", "}", "return", "RecyclerView", ".", "NO_ID", ";", "}" ]
Get the item Id for a given position @param position @return
[ "Get", "the", "item", "Id", "for", "a", "given", "position" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/adapter/BetterRecyclerAdapter.java#L431-L439
139,755
52inc/android-52Kit
library-eula/src/main/java/com/ftinc/kit/eula/EulaActivity.java
EulaActivity.createIntent
public static Intent createIntent(Context ctx, int logoResId, CharSequence eulaText){ Intent intent = new Intent(ctx, EulaActivity.class); intent.putExtra(EXTRA_LOGO, logoResId); intent.putExtra(EXTRA_EULA_TEXT, eulaText); return intent; }
java
public static Intent createIntent(Context ctx, int logoResId, CharSequence eulaText){ Intent intent = new Intent(ctx, EulaActivity.class); intent.putExtra(EXTRA_LOGO, logoResId); intent.putExtra(EXTRA_EULA_TEXT, eulaText); return intent; }
[ "public", "static", "Intent", "createIntent", "(", "Context", "ctx", ",", "int", "logoResId", ",", "CharSequence", "eulaText", ")", "{", "Intent", "intent", "=", "new", "Intent", "(", "ctx", ",", "EulaActivity", ".", "class", ")", ";", "intent", ".", "putExtra", "(", "EXTRA_LOGO", ",", "logoResId", ")", ";", "intent", ".", "putExtra", "(", "EXTRA_EULA_TEXT", ",", "eulaText", ")", ";", "return", "intent", ";", "}" ]
Generate a pre-populated intent to launch this activity with @param ctx the context to create the intent with @param logoResId the resource id of the logo you want to use @param eulaText the EULA text to display @return the intent to launch
[ "Generate", "a", "pre", "-", "populated", "intent", "to", "launch", "this", "activity", "with" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library-eula/src/main/java/com/ftinc/kit/eula/EulaActivity.java#L52-L57
139,756
52inc/android-52Kit
library-attributr/src/main/java/com/ftinc/kit/attributr/model/Library.java
Library.getLicenseText
public String getLicenseText(){ if(license != null){ return license.getLicense(description, year, author, email); } return "N/A"; }
java
public String getLicenseText(){ if(license != null){ return license.getLicense(description, year, author, email); } return "N/A"; }
[ "public", "String", "getLicenseText", "(", ")", "{", "if", "(", "license", "!=", "null", ")", "{", "return", "license", ".", "getLicense", "(", "description", ",", "year", ",", "author", ",", "email", ")", ";", "}", "return", "\"N/A\"", ";", "}" ]
Get the formatted license text for display @return the formatted user facing license text
[ "Get", "the", "formatted", "license", "text", "for", "display" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library-attributr/src/main/java/com/ftinc/kit/attributr/model/Library.java#L78-L83
139,757
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/MediaUtils.java
MediaUtils.getCameraCaptureIntent
public static Intent getCameraCaptureIntent(Context ctx, String authority){ Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); try { // Get the app's local file storage mCurrentCaptureUri = createAccessibleTempFile(ctx, authority); grantPermissions(ctx, mCurrentCaptureUri); intent.putExtra(MediaStore.EXTRA_OUTPUT, mCurrentCaptureUri); } catch (IOException e) { e.printStackTrace(); } return intent; }
java
public static Intent getCameraCaptureIntent(Context ctx, String authority){ Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); try { // Get the app's local file storage mCurrentCaptureUri = createAccessibleTempFile(ctx, authority); grantPermissions(ctx, mCurrentCaptureUri); intent.putExtra(MediaStore.EXTRA_OUTPUT, mCurrentCaptureUri); } catch (IOException e) { e.printStackTrace(); } return intent; }
[ "public", "static", "Intent", "getCameraCaptureIntent", "(", "Context", "ctx", ",", "String", "authority", ")", "{", "Intent", "intent", "=", "new", "Intent", "(", "MediaStore", ".", "ACTION_IMAGE_CAPTURE", ")", ";", "try", "{", "// Get the app's local file storage", "mCurrentCaptureUri", "=", "createAccessibleTempFile", "(", "ctx", ",", "authority", ")", ";", "grantPermissions", "(", "ctx", ",", "mCurrentCaptureUri", ")", ";", "intent", ".", "putExtra", "(", "MediaStore", ".", "EXTRA_OUTPUT", ",", "mCurrentCaptureUri", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "intent", ";", "}" ]
Generate the appropriate intent to launch the existing camera application to capture an image @see #CAPTURE_PHOTO_REQUEST_CODE @return the intent necessary to launch the camera to capture a photo
[ "Generate", "the", "appropriate", "intent", "to", "launch", "the", "existing", "camera", "application", "to", "capture", "an", "image" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/MediaUtils.java#L79-L91
139,758
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/MediaUtils.java
MediaUtils.getChooseMediaIntent
public static Intent getChooseMediaIntent(String mimeType){ Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType(mimeType); return intent; }
java
public static Intent getChooseMediaIntent(String mimeType){ Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType(mimeType); return intent; }
[ "public", "static", "Intent", "getChooseMediaIntent", "(", "String", "mimeType", ")", "{", "Intent", "intent", "=", "new", "Intent", "(", "Intent", ".", "ACTION_GET_CONTENT", ")", ";", "intent", ".", "addCategory", "(", "Intent", ".", "CATEGORY_OPENABLE", ")", ";", "intent", ".", "setType", "(", "mimeType", ")", ";", "return", "intent", ";", "}" ]
Generate the appropriate intent to launch the document chooser to allow the user to pick an image to upload. @see #PICK_MEDIA_REQUEST_CODE @param mimeType the MIME type you want to constrict the chooser to @return the choose media intent
[ "Generate", "the", "appropriate", "intent", "to", "launch", "the", "document", "chooser", "to", "allow", "the", "user", "to", "pick", "an", "image", "to", "upload", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/MediaUtils.java#L101-L106
139,759
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/MediaUtils.java
MediaUtils.handleActivityResult
public static Observable<File> handleActivityResult(final Context context, int resultCode, int requestCode, Intent data){ if(resultCode == Activity.RESULT_OK){ switch (requestCode){ case CAPTURE_PHOTO_REQUEST_CODE: if(mCurrentCaptureUri != null){ revokePermissions(context, mCurrentCaptureUri); File file = getAccessibleTempFile(context, mCurrentCaptureUri); mCurrentCaptureUri = null; return Observable.just(file); } return Observable.error(new FileNotFoundException("Unable to find camera capture")); case PICK_MEDIA_REQUEST_CODE: final Uri mediaUri = data.getData(); final String fileName = getFileName(context, mediaUri); if(mediaUri != null){ return Observable.fromCallable(new Callable<File>() { @Override public File call() throws Exception { ParcelFileDescriptor parcelFileDescriptor = null; try { parcelFileDescriptor = context.getContentResolver().openFileDescriptor(mediaUri, "r"); // Now that we have the file description, get the associated input stream FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor(); FileInputStream fis = new FileInputStream(fileDescriptor); FileOutputStream fos = null; // Generate temporary output file and output file data to it try { File tempFile = createTempFile(context, fileName); fos = new FileOutputStream(tempFile); byte[] buffer = new byte[1024]; int len; while ((len = fis.read(buffer)) > 0) { fos.write(buffer, 0, len); } return tempFile; } catch (IOException e) { throw OnErrorThrowable.from(e); } finally { try { parcelFileDescriptor.close(); fis.close(); if (fos != null) { fos.close(); } } catch (IOException e1) { e1.printStackTrace(); } } } catch (FileNotFoundException e) { throw OnErrorThrowable.from(e); } } }).compose(RxUtils.<File>applyWorkSchedulers()); } return Observable.error(new FileNotFoundException("Unable to load selected file")); default: return Observable.empty(); } } return Observable.empty(); }
java
public static Observable<File> handleActivityResult(final Context context, int resultCode, int requestCode, Intent data){ if(resultCode == Activity.RESULT_OK){ switch (requestCode){ case CAPTURE_PHOTO_REQUEST_CODE: if(mCurrentCaptureUri != null){ revokePermissions(context, mCurrentCaptureUri); File file = getAccessibleTempFile(context, mCurrentCaptureUri); mCurrentCaptureUri = null; return Observable.just(file); } return Observable.error(new FileNotFoundException("Unable to find camera capture")); case PICK_MEDIA_REQUEST_CODE: final Uri mediaUri = data.getData(); final String fileName = getFileName(context, mediaUri); if(mediaUri != null){ return Observable.fromCallable(new Callable<File>() { @Override public File call() throws Exception { ParcelFileDescriptor parcelFileDescriptor = null; try { parcelFileDescriptor = context.getContentResolver().openFileDescriptor(mediaUri, "r"); // Now that we have the file description, get the associated input stream FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor(); FileInputStream fis = new FileInputStream(fileDescriptor); FileOutputStream fos = null; // Generate temporary output file and output file data to it try { File tempFile = createTempFile(context, fileName); fos = new FileOutputStream(tempFile); byte[] buffer = new byte[1024]; int len; while ((len = fis.read(buffer)) > 0) { fos.write(buffer, 0, len); } return tempFile; } catch (IOException e) { throw OnErrorThrowable.from(e); } finally { try { parcelFileDescriptor.close(); fis.close(); if (fos != null) { fos.close(); } } catch (IOException e1) { e1.printStackTrace(); } } } catch (FileNotFoundException e) { throw OnErrorThrowable.from(e); } } }).compose(RxUtils.<File>applyWorkSchedulers()); } return Observable.error(new FileNotFoundException("Unable to load selected file")); default: return Observable.empty(); } } return Observable.empty(); }
[ "public", "static", "Observable", "<", "File", ">", "handleActivityResult", "(", "final", "Context", "context", ",", "int", "resultCode", ",", "int", "requestCode", ",", "Intent", "data", ")", "{", "if", "(", "resultCode", "==", "Activity", ".", "RESULT_OK", ")", "{", "switch", "(", "requestCode", ")", "{", "case", "CAPTURE_PHOTO_REQUEST_CODE", ":", "if", "(", "mCurrentCaptureUri", "!=", "null", ")", "{", "revokePermissions", "(", "context", ",", "mCurrentCaptureUri", ")", ";", "File", "file", "=", "getAccessibleTempFile", "(", "context", ",", "mCurrentCaptureUri", ")", ";", "mCurrentCaptureUri", "=", "null", ";", "return", "Observable", ".", "just", "(", "file", ")", ";", "}", "return", "Observable", ".", "error", "(", "new", "FileNotFoundException", "(", "\"Unable to find camera capture\"", ")", ")", ";", "case", "PICK_MEDIA_REQUEST_CODE", ":", "final", "Uri", "mediaUri", "=", "data", ".", "getData", "(", ")", ";", "final", "String", "fileName", "=", "getFileName", "(", "context", ",", "mediaUri", ")", ";", "if", "(", "mediaUri", "!=", "null", ")", "{", "return", "Observable", ".", "fromCallable", "(", "new", "Callable", "<", "File", ">", "(", ")", "{", "@", "Override", "public", "File", "call", "(", ")", "throws", "Exception", "{", "ParcelFileDescriptor", "parcelFileDescriptor", "=", "null", ";", "try", "{", "parcelFileDescriptor", "=", "context", ".", "getContentResolver", "(", ")", ".", "openFileDescriptor", "(", "mediaUri", ",", "\"r\"", ")", ";", "// Now that we have the file description, get the associated input stream", "FileDescriptor", "fileDescriptor", "=", "parcelFileDescriptor", ".", "getFileDescriptor", "(", ")", ";", "FileInputStream", "fis", "=", "new", "FileInputStream", "(", "fileDescriptor", ")", ";", "FileOutputStream", "fos", "=", "null", ";", "// Generate temporary output file and output file data to it", "try", "{", "File", "tempFile", "=", "createTempFile", "(", "context", ",", "fileName", ")", ";", "fos", "=", "new", "FileOutputStream", "(", "tempFile", ")", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "1024", "]", ";", "int", "len", ";", "while", "(", "(", "len", "=", "fis", ".", "read", "(", "buffer", ")", ")", ">", "0", ")", "{", "fos", ".", "write", "(", "buffer", ",", "0", ",", "len", ")", ";", "}", "return", "tempFile", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "OnErrorThrowable", ".", "from", "(", "e", ")", ";", "}", "finally", "{", "try", "{", "parcelFileDescriptor", ".", "close", "(", ")", ";", "fis", ".", "close", "(", ")", ";", "if", "(", "fos", "!=", "null", ")", "{", "fos", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "IOException", "e1", ")", "{", "e1", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "throw", "OnErrorThrowable", ".", "from", "(", "e", ")", ";", "}", "}", "}", ")", ".", "compose", "(", "RxUtils", ".", "<", "File", ">", "applyWorkSchedulers", "(", ")", ")", ";", "}", "return", "Observable", ".", "error", "(", "new", "FileNotFoundException", "(", "\"Unable to load selected file\"", ")", ")", ";", "default", ":", "return", "Observable", ".", "empty", "(", ")", ";", "}", "}", "return", "Observable", ".", "empty", "(", ")", ";", "}" ]
Handle the activity result of an intent launched to capture a photo or choose an image @see #getCameraCaptureIntent(Context, String) @see #getChooseMediaIntent(String) @param context the activity context @param resultCode the result of the return code @param requestCode the request code that launched the activity that caused the result @param data the data from the result
[ "Handle", "the", "activity", "result", "of", "an", "intent", "launched", "to", "capture", "a", "photo", "or", "choose", "an", "image" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/MediaUtils.java#L125-L194
139,760
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/MediaUtils.java
MediaUtils.createAccessibleTempFile
private static Uri createAccessibleTempFile(Context ctx, String authority) throws IOException { File dir = new File(ctx.getCacheDir(), "camera"); File tmp = createTempFile(dir); // Give permissions return FileProvider.getUriForFile(ctx, authority, tmp); }
java
private static Uri createAccessibleTempFile(Context ctx, String authority) throws IOException { File dir = new File(ctx.getCacheDir(), "camera"); File tmp = createTempFile(dir); // Give permissions return FileProvider.getUriForFile(ctx, authority, tmp); }
[ "private", "static", "Uri", "createAccessibleTempFile", "(", "Context", "ctx", ",", "String", "authority", ")", "throws", "IOException", "{", "File", "dir", "=", "new", "File", "(", "ctx", ".", "getCacheDir", "(", ")", ",", "\"camera\"", ")", ";", "File", "tmp", "=", "createTempFile", "(", "dir", ")", ";", "// Give permissions", "return", "FileProvider", ".", "getUriForFile", "(", "ctx", ",", "authority", ",", "tmp", ")", ";", "}" ]
Generate an accessible temporary file URI to be used for camera captures @param ctx @return @throws IOException
[ "Generate", "an", "accessible", "temporary", "file", "URI", "to", "be", "used", "for", "camera", "captures" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/MediaUtils.java#L236-L242
139,761
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/MediaUtils.java
MediaUtils.grantPermissions
private static void grantPermissions(Context ctx, Uri uri){ Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); List<ResolveInfo> resolvedIntentActivities = ctx.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolvedIntentInfo : resolvedIntentActivities) { String packageName = resolvedIntentInfo.activityInfo.packageName; // Grant Permissions ctx.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); } }
java
private static void grantPermissions(Context ctx, Uri uri){ Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); List<ResolveInfo> resolvedIntentActivities = ctx.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolvedIntentInfo : resolvedIntentActivities) { String packageName = resolvedIntentInfo.activityInfo.packageName; // Grant Permissions ctx.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); } }
[ "private", "static", "void", "grantPermissions", "(", "Context", "ctx", ",", "Uri", "uri", ")", "{", "Intent", "intent", "=", "new", "Intent", "(", "MediaStore", ".", "ACTION_IMAGE_CAPTURE", ")", ";", "List", "<", "ResolveInfo", ">", "resolvedIntentActivities", "=", "ctx", ".", "getPackageManager", "(", ")", ".", "queryIntentActivities", "(", "intent", ",", "PackageManager", ".", "MATCH_DEFAULT_ONLY", ")", ";", "for", "(", "ResolveInfo", "resolvedIntentInfo", ":", "resolvedIntentActivities", ")", "{", "String", "packageName", "=", "resolvedIntentInfo", ".", "activityInfo", ".", "packageName", ";", "// Grant Permissions", "ctx", ".", "grantUriPermission", "(", "packageName", ",", "uri", ",", "Intent", ".", "FLAG_GRANT_WRITE_URI_PERMISSION", "|", "Intent", ".", "FLAG_GRANT_READ_URI_PERMISSION", ")", ";", "}", "}" ]
Grant URI permissions for all potential camera applications that can handle the capture intent.
[ "Grant", "URI", "permissions", "for", "all", "potential", "camera", "applications", "that", "can", "handle", "the", "capture", "intent", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/MediaUtils.java#L255-L266
139,762
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/MediaUtils.java
MediaUtils.revokePermissions
private static void revokePermissions(Context ctx, Uri uri){ ctx.revokeUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); }
java
private static void revokePermissions(Context ctx, Uri uri){ ctx.revokeUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); }
[ "private", "static", "void", "revokePermissions", "(", "Context", "ctx", ",", "Uri", "uri", ")", "{", "ctx", ".", "revokeUriPermission", "(", "uri", ",", "Intent", ".", "FLAG_GRANT_WRITE_URI_PERMISSION", "|", "Intent", ".", "FLAG_GRANT_READ_URI_PERMISSION", ")", ";", "}" ]
Revoke URI permissions to a specific URI that had been previously granted
[ "Revoke", "URI", "permissions", "to", "a", "specific", "URI", "that", "had", "been", "previously", "granted" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/MediaUtils.java#L271-L275
139,763
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/MediaUtils.java
MediaUtils.cleanFilename
public static String cleanFilename(String fileName){ int lastIndex = fileName.lastIndexOf("."); return fileName.substring(0, lastIndex); }
java
public static String cleanFilename(String fileName){ int lastIndex = fileName.lastIndexOf("."); return fileName.substring(0, lastIndex); }
[ "public", "static", "String", "cleanFilename", "(", "String", "fileName", ")", "{", "int", "lastIndex", "=", "fileName", ".", "lastIndexOf", "(", "\".\"", ")", ";", "return", "fileName", ".", "substring", "(", "0", ",", "lastIndex", ")", ";", "}" ]
Clean the extension off of the file name. @param fileName the full file name @return The cleaned file name
[ "Clean", "the", "extension", "off", "of", "the", "file", "name", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/MediaUtils.java#L304-L307
139,764
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/Utils.java
Utils.isEmulator
public static boolean isEmulator(){ return "google_sdk".equals(Build.PRODUCT) || Build.PRODUCT.contains("sdk_google_phone") || "sdk".equals(Build.PRODUCT) || "sdk_x86".equals(Build.PRODUCT) || "vbox86p".equals(Build.PRODUCT); }
java
public static boolean isEmulator(){ return "google_sdk".equals(Build.PRODUCT) || Build.PRODUCT.contains("sdk_google_phone") || "sdk".equals(Build.PRODUCT) || "sdk_x86".equals(Build.PRODUCT) || "vbox86p".equals(Build.PRODUCT); }
[ "public", "static", "boolean", "isEmulator", "(", ")", "{", "return", "\"google_sdk\"", ".", "equals", "(", "Build", ".", "PRODUCT", ")", "||", "Build", ".", "PRODUCT", ".", "contains", "(", "\"sdk_google_phone\"", ")", "||", "\"sdk\"", ".", "equals", "(", "Build", ".", "PRODUCT", ")", "||", "\"sdk_x86\"", ".", "equals", "(", "Build", ".", "PRODUCT", ")", "||", "\"vbox86p\"", ".", "equals", "(", "Build", ".", "PRODUCT", ")", ";", "}" ]
Return whether or not the current device is an emulator
[ "Return", "whether", "or", "not", "the", "current", "device", "is", "an", "emulator" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/Utils.java#L85-L91
139,765
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/Utils.java
Utils.getGMTOffset
public static int getGMTOffset(){ Calendar now = Calendar.getInstance(); return (now.get(Calendar.ZONE_OFFSET) + now.get(Calendar.DST_OFFSET)) / 3600000; }
java
public static int getGMTOffset(){ Calendar now = Calendar.getInstance(); return (now.get(Calendar.ZONE_OFFSET) + now.get(Calendar.DST_OFFSET)) / 3600000; }
[ "public", "static", "int", "getGMTOffset", "(", ")", "{", "Calendar", "now", "=", "Calendar", ".", "getInstance", "(", ")", ";", "return", "(", "now", ".", "get", "(", "Calendar", ".", "ZONE_OFFSET", ")", "+", "now", ".", "get", "(", "Calendar", ".", "DST_OFFSET", ")", ")", "/", "3600000", ";", "}" ]
Get the Device's GMT Offset @return the gmt offset in hours
[ "Get", "the", "Device", "s", "GMT", "Offset" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/Utils.java#L121-L124
139,766
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/Utils.java
Utils.getMimeType
public static String getMimeType(String url) { String type = null; String extension = MimeTypeMap.getFileExtensionFromUrl(url); if (extension != null) { MimeTypeMap mime = MimeTypeMap.getSingleton(); type = mime.getMimeTypeFromExtension(extension); } return type; }
java
public static String getMimeType(String url) { String type = null; String extension = MimeTypeMap.getFileExtensionFromUrl(url); if (extension != null) { MimeTypeMap mime = MimeTypeMap.getSingleton(); type = mime.getMimeTypeFromExtension(extension); } return type; }
[ "public", "static", "String", "getMimeType", "(", "String", "url", ")", "{", "String", "type", "=", "null", ";", "String", "extension", "=", "MimeTypeMap", ".", "getFileExtensionFromUrl", "(", "url", ")", ";", "if", "(", "extension", "!=", "null", ")", "{", "MimeTypeMap", "mime", "=", "MimeTypeMap", ".", "getSingleton", "(", ")", ";", "type", "=", "mime", ".", "getMimeTypeFromExtension", "(", "extension", ")", ";", "}", "return", "type", ";", "}" ]
Get the MIME type of a file @param url @return
[ "Get", "the", "MIME", "type", "of", "a", "file" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/Utils.java#L131-L140
139,767
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/Utils.java
Utils.distance
public static float distance(PointF p1, PointF p2){ return (float) Math.sqrt(Math.pow((p2.x - p1.x), 2) + Math.pow(p2.y - p1.y,2)); }
java
public static float distance(PointF p1, PointF p2){ return (float) Math.sqrt(Math.pow((p2.x - p1.x), 2) + Math.pow(p2.y - p1.y,2)); }
[ "public", "static", "float", "distance", "(", "PointF", "p1", ",", "PointF", "p2", ")", "{", "return", "(", "float", ")", "Math", ".", "sqrt", "(", "Math", ".", "pow", "(", "(", "p2", ".", "x", "-", "p1", ".", "x", ")", ",", "2", ")", "+", "Math", ".", "pow", "(", "p2", ".", "y", "-", "p1", ".", "y", ",", "2", ")", ")", ";", "}" ]
Compute the distance between two points @param p1 the first point @param p2 the second point @return the distance between the two points
[ "Compute", "the", "distance", "between", "two", "points" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/Utils.java#L167-L169
139,768
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/Utils.java
Utils.parseFloat
public static float parseFloat(String val, float defVal){ if(TextUtils.isEmpty(val)) return defVal; try{ return Float.parseFloat(val); }catch (NumberFormatException e){ return defVal; } }
java
public static float parseFloat(String val, float defVal){ if(TextUtils.isEmpty(val)) return defVal; try{ return Float.parseFloat(val); }catch (NumberFormatException e){ return defVal; } }
[ "public", "static", "float", "parseFloat", "(", "String", "val", ",", "float", "defVal", ")", "{", "if", "(", "TextUtils", ".", "isEmpty", "(", "val", ")", ")", "return", "defVal", ";", "try", "{", "return", "Float", ".", "parseFloat", "(", "val", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "return", "defVal", ";", "}", "}" ]
Parse a float from a String in a safe manner. @param val the string to parse @param defVal the default value to return if parsing fails @return the parsed float, or default value
[ "Parse", "a", "float", "from", "a", "String", "in", "a", "safe", "manner", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/Utils.java#L246-L253
139,769
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/Utils.java
Utils.parseInt
public static int parseInt(String val, int defValue){ if(TextUtils.isEmpty(val)) return defValue; try{ return Integer.parseInt(val); }catch (NumberFormatException e){ return defValue; } }
java
public static int parseInt(String val, int defValue){ if(TextUtils.isEmpty(val)) return defValue; try{ return Integer.parseInt(val); }catch (NumberFormatException e){ return defValue; } }
[ "public", "static", "int", "parseInt", "(", "String", "val", ",", "int", "defValue", ")", "{", "if", "(", "TextUtils", ".", "isEmpty", "(", "val", ")", ")", "return", "defValue", ";", "try", "{", "return", "Integer", ".", "parseInt", "(", "val", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "return", "defValue", ";", "}", "}" ]
Parse a int from a String in a safe manner. @param val the string to parse @param defValue the default value to return if parsing fails @return the parsed int, or default value
[ "Parse", "a", "int", "from", "a", "String", "in", "a", "safe", "manner", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/Utils.java#L262-L269
139,770
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/Utils.java
Utils.parseLong
public static long parseLong(String val, long defValue){ if(TextUtils.isEmpty(val)) return defValue; try{ return Long.parseLong(val); }catch (NumberFormatException e){ return defValue; } }
java
public static long parseLong(String val, long defValue){ if(TextUtils.isEmpty(val)) return defValue; try{ return Long.parseLong(val); }catch (NumberFormatException e){ return defValue; } }
[ "public", "static", "long", "parseLong", "(", "String", "val", ",", "long", "defValue", ")", "{", "if", "(", "TextUtils", ".", "isEmpty", "(", "val", ")", ")", "return", "defValue", ";", "try", "{", "return", "Long", ".", "parseLong", "(", "val", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "return", "defValue", ";", "}", "}" ]
Parse a long from a String in a safe manner. @param val the string to parse @param defValue the default value to return if parsing fails @return the parsed long, or default value
[ "Parse", "a", "long", "from", "a", "String", "in", "a", "safe", "manner", "." ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/Utils.java#L278-L285
139,771
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/util/Utils.java
Utils.parseDouble
public static double parseDouble(String val, double defValue){ if(TextUtils.isEmpty(val)) return defValue; try{ return Double.parseDouble(val); }catch(NumberFormatException e){ return defValue; } }
java
public static double parseDouble(String val, double defValue){ if(TextUtils.isEmpty(val)) return defValue; try{ return Double.parseDouble(val); }catch(NumberFormatException e){ return defValue; } }
[ "public", "static", "double", "parseDouble", "(", "String", "val", ",", "double", "defValue", ")", "{", "if", "(", "TextUtils", ".", "isEmpty", "(", "val", ")", ")", "return", "defValue", ";", "try", "{", "return", "Double", ".", "parseDouble", "(", "val", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "return", "defValue", ";", "}", "}" ]
Parse a double from a String in a safe manner @param val the string to parse @param defValue the default value to return in parsing fails @return the parsed double, or default value
[ "Parse", "a", "double", "from", "a", "String", "in", "a", "safe", "manner" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/Utils.java#L294-L301
139,772
52inc/android-52Kit
library-winds/src/main/java/com/ftinc/kit/winds/ui/ChangeLogActivity.java
ChangeLogActivity.configAppBar
private void configAppBar(){ setSupportActionBar(mAppbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle(R.string.changelog_activity_title); mAppbar.setNavigationOnClickListener(this); }
java
private void configAppBar(){ setSupportActionBar(mAppbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle(R.string.changelog_activity_title); mAppbar.setNavigationOnClickListener(this); }
[ "private", "void", "configAppBar", "(", ")", "{", "setSupportActionBar", "(", "mAppbar", ")", ";", "getSupportActionBar", "(", ")", ".", "setDisplayHomeAsUpEnabled", "(", "true", ")", ";", "getSupportActionBar", "(", ")", ".", "setTitle", "(", "R", ".", "string", ".", "changelog_activity_title", ")", ";", "mAppbar", ".", "setNavigationOnClickListener", "(", "this", ")", ";", "}" ]
Configure the Appbar
[ "Configure", "the", "Appbar" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library-winds/src/main/java/com/ftinc/kit/winds/ui/ChangeLogActivity.java#L119-L124
139,773
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/font/FontLoader.java
FontLoader.apply
public static void apply(TextView textView, Face type){ // First check for existing typefaces Typeface typeface = getTypeface(textView.getContext(), type); if (typeface != null) textView.setTypeface(typeface); }
java
public static void apply(TextView textView, Face type){ // First check for existing typefaces Typeface typeface = getTypeface(textView.getContext(), type); if (typeface != null) textView.setTypeface(typeface); }
[ "public", "static", "void", "apply", "(", "TextView", "textView", ",", "Face", "type", ")", "{", "// First check for existing typefaces", "Typeface", "typeface", "=", "getTypeface", "(", "textView", ".", "getContext", "(", ")", ",", "type", ")", ";", "if", "(", "typeface", "!=", "null", ")", "textView", ".", "setTypeface", "(", "typeface", ")", ";", "}" ]
Apply a typeface to a textview @see Face @param textView the text view you wish to apply to @param type the typeface to apply
[ "Apply", "a", "typeface", "to", "a", "textview" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/font/FontLoader.java#L51-L56
139,774
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/font/FontLoader.java
FontLoader.apply
public static void apply(Face type, TextView... textViews){ if(textViews.length == 0) return; for (int i = 0; i < textViews.length; i++) { apply(textViews[i], type); } }
java
public static void apply(Face type, TextView... textViews){ if(textViews.length == 0) return; for (int i = 0; i < textViews.length; i++) { apply(textViews[i], type); } }
[ "public", "static", "void", "apply", "(", "Face", "type", ",", "TextView", "...", "textViews", ")", "{", "if", "(", "textViews", ".", "length", "==", "0", ")", "return", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "textViews", ".", "length", ";", "i", "++", ")", "{", "apply", "(", "textViews", "[", "i", "]", ",", "type", ")", ";", "}", "}" ]
Apply a typeface to one or many textviews @param type the typeface to apply @param textViews the one or many textviews to apply to
[ "Apply", "a", "typeface", "to", "one", "or", "many", "textviews" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/font/FontLoader.java#L64-L69
139,775
52inc/android-52Kit
library/src/main/java/com/ftinc/kit/font/FontLoader.java
FontLoader.getTypeface
public static Typeface getTypeface(Context ctx, Face type){ return getTypeface(ctx, "fonts/" + type.getFontFileName()); }
java
public static Typeface getTypeface(Context ctx, Face type){ return getTypeface(ctx, "fonts/" + type.getFontFileName()); }
[ "public", "static", "Typeface", "getTypeface", "(", "Context", "ctx", ",", "Face", "type", ")", "{", "return", "getTypeface", "(", "ctx", ",", "\"fonts/\"", "+", "type", ".", "getFontFileName", "(", ")", ")", ";", "}" ]
Get a Roboto typeface for a given string type @param ctx the application context @param type the typeface type argument @return the loaded typeface, or null
[ "Get", "a", "Roboto", "typeface", "for", "a", "given", "string", "type" ]
8644fab0f633477b1bb1dddd8147a9ef8bc03516
https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/font/FontLoader.java#L104-L106
139,776
opendigitaleducation/web-utils
src/main/java/org/vertx/java/busmods/BusModBase.java
BusModBase.start
public void start() { eb = vertx.eventBus(); config = config(); FileResolver.getInstance().setBasePath(config); }
java
public void start() { eb = vertx.eventBus(); config = config(); FileResolver.getInstance().setBasePath(config); }
[ "public", "void", "start", "(", ")", "{", "eb", "=", "vertx", ".", "eventBus", "(", ")", ";", "config", "=", "config", "(", ")", ";", "FileResolver", ".", "getInstance", "(", ")", ".", "setBasePath", "(", "config", ")", ";", "}" ]
Start the busmod
[ "Start", "the", "busmod" ]
5c12f7e8781a9a0fbbe7b8d9fb741627aa97a1e3
https://github.com/opendigitaleducation/web-utils/blob/5c12f7e8781a9a0fbbe7b8d9fb741627aa97a1e3/src/main/java/org/vertx/java/busmods/BusModBase.java#L44-L48
139,777
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/planner/opt/TablePlanner.java
TablePlanner.makeSelectPlan
public Plan makeSelectPlan() { Plan p = makeIndexSelectPlan(); if (p == null) p = tp; return addSelectPredicate(p); }
java
public Plan makeSelectPlan() { Plan p = makeIndexSelectPlan(); if (p == null) p = tp; return addSelectPredicate(p); }
[ "public", "Plan", "makeSelectPlan", "(", ")", "{", "Plan", "p", "=", "makeIndexSelectPlan", "(", ")", ";", "if", "(", "p", "==", "null", ")", "p", "=", "tp", ";", "return", "addSelectPredicate", "(", "p", ")", ";", "}" ]
Constructs a select plan for the table. The plan will use an indexselect, if possible. @return a select plan for the table.
[ "Constructs", "a", "select", "plan", "for", "the", "table", ".", "The", "plan", "will", "use", "an", "indexselect", "if", "possible", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/planner/opt/TablePlanner.java#L94-L99
139,778
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/planner/opt/TablePlanner.java
TablePlanner.makeJoinPlan
public Plan makeJoinPlan(Plan trunk) { Schema trunkSch = trunk.schema(); Predicate joinPred = pred.joinPredicate(sch, trunkSch); if (joinPred == null) return null; Plan p = makeIndexJoinPlan(trunk, trunkSch); if (p == null) p = makeProductJoinPlan(trunk, trunkSch); return p; }
java
public Plan makeJoinPlan(Plan trunk) { Schema trunkSch = trunk.schema(); Predicate joinPred = pred.joinPredicate(sch, trunkSch); if (joinPred == null) return null; Plan p = makeIndexJoinPlan(trunk, trunkSch); if (p == null) p = makeProductJoinPlan(trunk, trunkSch); return p; }
[ "public", "Plan", "makeJoinPlan", "(", "Plan", "trunk", ")", "{", "Schema", "trunkSch", "=", "trunk", ".", "schema", "(", ")", ";", "Predicate", "joinPred", "=", "pred", ".", "joinPredicate", "(", "sch", ",", "trunkSch", ")", ";", "if", "(", "joinPred", "==", "null", ")", "return", "null", ";", "Plan", "p", "=", "makeIndexJoinPlan", "(", "trunk", ",", "trunkSch", ")", ";", "if", "(", "p", "==", "null", ")", "p", "=", "makeProductJoinPlan", "(", "trunk", ",", "trunkSch", ")", ";", "return", "p", ";", "}" ]
Constructs a join plan of the specified trunk and this table. The plan will use an indexjoin, if possible; otherwise a multi-buffer product join. The method returns null if no join is possible. <p> The select predicate applicable to this table is pushed down below the join. </p> @param trunk the specified trunk of join @return a join plan of the trunk and this table
[ "Constructs", "a", "join", "plan", "of", "the", "specified", "trunk", "and", "this", "table", ".", "The", "plan", "will", "use", "an", "indexjoin", "if", "possible", ";", "otherwise", "a", "multi", "-", "buffer", "product", "join", ".", "The", "method", "returns", "null", "if", "no", "join", "is", "possible", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/planner/opt/TablePlanner.java#L115-L124
139,779
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/planner/opt/TablePlanner.java
TablePlanner.makeProductPlan
public Plan makeProductPlan(Plan trunk) { Plan p = makeSelectPlan(); return new MultiBufferProductPlan(trunk, p, tx); }
java
public Plan makeProductPlan(Plan trunk) { Plan p = makeSelectPlan(); return new MultiBufferProductPlan(trunk, p, tx); }
[ "public", "Plan", "makeProductPlan", "(", "Plan", "trunk", ")", "{", "Plan", "p", "=", "makeSelectPlan", "(", ")", ";", "return", "new", "MultiBufferProductPlan", "(", "trunk", ",", "p", ",", "tx", ")", ";", "}" ]
Constructs a product plan of the specified trunk and this table. <p> The select predicate applicable to this table is pushed down below the product. </p> @param trunk the specified trunk of join @return a product plan of the trunk and this table
[ "Constructs", "a", "product", "plan", "of", "the", "specified", "trunk", "and", "this", "table", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/planner/opt/TablePlanner.java#L138-L141
139,780
constantcontact/java-sdk
sdk-rx/src/main/java/com/constantcontact/v2/CCApi2.java
CCApi2.getAccountService
public AccountService getAccountService() { if (_accountService == null) { synchronized (CCApi2.class) { if (_accountService == null) { _accountService = _retrofit.create(AccountService.class); } } } return _accountService; }
java
public AccountService getAccountService() { if (_accountService == null) { synchronized (CCApi2.class) { if (_accountService == null) { _accountService = _retrofit.create(AccountService.class); } } } return _accountService; }
[ "public", "AccountService", "getAccountService", "(", ")", "{", "if", "(", "_accountService", "==", "null", ")", "{", "synchronized", "(", "CCApi2", ".", "class", ")", "{", "if", "(", "_accountService", "==", "null", ")", "{", "_accountService", "=", "_retrofit", ".", "create", "(", "AccountService", ".", "class", ")", ";", "}", "}", "}", "return", "_accountService", ";", "}" ]
Gets the account service. @return the account service
[ "Gets", "the", "account", "service", "." ]
08b176505b8c55073245f38a56d1d9e14a3ccb37
https://github.com/constantcontact/java-sdk/blob/08b176505b8c55073245f38a56d1d9e14a3ccb37/sdk-rx/src/main/java/com/constantcontact/v2/CCApi2.java#L91-L101
139,781
constantcontact/java-sdk
sdk-rx/src/main/java/com/constantcontact/v2/CCApi2.java
CCApi2.getCampaignService
public CampaignService getCampaignService() { if (_campaignService == null) { synchronized (CCApi2.class) { if (_campaignService == null) { _campaignService = _retrofit.create(CampaignService.class); } } } return _campaignService; }
java
public CampaignService getCampaignService() { if (_campaignService == null) { synchronized (CCApi2.class) { if (_campaignService == null) { _campaignService = _retrofit.create(CampaignService.class); } } } return _campaignService; }
[ "public", "CampaignService", "getCampaignService", "(", ")", "{", "if", "(", "_campaignService", "==", "null", ")", "{", "synchronized", "(", "CCApi2", ".", "class", ")", "{", "if", "(", "_campaignService", "==", "null", ")", "{", "_campaignService", "=", "_retrofit", ".", "create", "(", "CampaignService", ".", "class", ")", ";", "}", "}", "}", "return", "_campaignService", ";", "}" ]
Gets the campaign service. @return the campaign service
[ "Gets", "the", "campaign", "service", "." ]
08b176505b8c55073245f38a56d1d9e14a3ccb37
https://github.com/constantcontact/java-sdk/blob/08b176505b8c55073245f38a56d1d9e14a3ccb37/sdk-rx/src/main/java/com/constantcontact/v2/CCApi2.java#L108-L118
139,782
constantcontact/java-sdk
sdk-rx/src/main/java/com/constantcontact/v2/CCApi2.java
CCApi2.getContactService
public ContactService getContactService() { if (_contactService == null) { synchronized (CCApi2.class) { if (_contactService == null) { _contactService = _retrofit.create(ContactService.class); } } } return _contactService; }
java
public ContactService getContactService() { if (_contactService == null) { synchronized (CCApi2.class) { if (_contactService == null) { _contactService = _retrofit.create(ContactService.class); } } } return _contactService; }
[ "public", "ContactService", "getContactService", "(", ")", "{", "if", "(", "_contactService", "==", "null", ")", "{", "synchronized", "(", "CCApi2", ".", "class", ")", "{", "if", "(", "_contactService", "==", "null", ")", "{", "_contactService", "=", "_retrofit", ".", "create", "(", "ContactService", ".", "class", ")", ";", "}", "}", "}", "return", "_contactService", ";", "}" ]
Gets the contact service. @return the contact service
[ "Gets", "the", "contact", "service", "." ]
08b176505b8c55073245f38a56d1d9e14a3ccb37
https://github.com/constantcontact/java-sdk/blob/08b176505b8c55073245f38a56d1d9e14a3ccb37/sdk-rx/src/main/java/com/constantcontact/v2/CCApi2.java#L125-L135
139,783
constantcontact/java-sdk
sdk-rx/src/main/java/com/constantcontact/v2/CCApi2.java
CCApi2.getLibraryService
public LibraryService getLibraryService() { if (_libraryService == null) { synchronized (CCApi2.class) { if (_libraryService == null) { _libraryService = _retrofit.create(LibraryService.class); } } } return _libraryService; }
java
public LibraryService getLibraryService() { if (_libraryService == null) { synchronized (CCApi2.class) { if (_libraryService == null) { _libraryService = _retrofit.create(LibraryService.class); } } } return _libraryService; }
[ "public", "LibraryService", "getLibraryService", "(", ")", "{", "if", "(", "_libraryService", "==", "null", ")", "{", "synchronized", "(", "CCApi2", ".", "class", ")", "{", "if", "(", "_libraryService", "==", "null", ")", "{", "_libraryService", "=", "_retrofit", ".", "create", "(", "LibraryService", ".", "class", ")", ";", "}", "}", "}", "return", "_libraryService", ";", "}" ]
Gets the library service. @return the library service
[ "Gets", "the", "library", "service", "." ]
08b176505b8c55073245f38a56d1d9e14a3ccb37
https://github.com/constantcontact/java-sdk/blob/08b176505b8c55073245f38a56d1d9e14a3ccb37/sdk-rx/src/main/java/com/constantcontact/v2/CCApi2.java#L142-L152
139,784
constantcontact/java-sdk
sdk-rx/src/main/java/com/constantcontact/v2/CCApi2.java
CCApi2.getCampaignTrackingService
public CampaignTrackingService getCampaignTrackingService() { if (_campaignTrackingService == null) { synchronized (CCApi2.class) { if (_campaignTrackingService == null) { _campaignTrackingService = _retrofit.create(CampaignTrackingService.class); } } } return _campaignTrackingService; }
java
public CampaignTrackingService getCampaignTrackingService() { if (_campaignTrackingService == null) { synchronized (CCApi2.class) { if (_campaignTrackingService == null) { _campaignTrackingService = _retrofit.create(CampaignTrackingService.class); } } } return _campaignTrackingService; }
[ "public", "CampaignTrackingService", "getCampaignTrackingService", "(", ")", "{", "if", "(", "_campaignTrackingService", "==", "null", ")", "{", "synchronized", "(", "CCApi2", ".", "class", ")", "{", "if", "(", "_campaignTrackingService", "==", "null", ")", "{", "_campaignTrackingService", "=", "_retrofit", ".", "create", "(", "CampaignTrackingService", ".", "class", ")", ";", "}", "}", "}", "return", "_campaignTrackingService", ";", "}" ]
Gets the campaign tracking service. @return the campaign tracking service
[ "Gets", "the", "campaign", "tracking", "service", "." ]
08b176505b8c55073245f38a56d1d9e14a3ccb37
https://github.com/constantcontact/java-sdk/blob/08b176505b8c55073245f38a56d1d9e14a3ccb37/sdk-rx/src/main/java/com/constantcontact/v2/CCApi2.java#L159-L169
139,785
constantcontact/java-sdk
sdk-rx/src/main/java/com/constantcontact/v2/CCApi2.java
CCApi2.getContactTrackingService
public ContactTrackingService getContactTrackingService() { if (_contactTrackingService == null) { synchronized (CCApi2.class) { if (_contactTrackingService == null) { _contactTrackingService = _retrofit.create(ContactTrackingService.class); } } } return _contactTrackingService; }
java
public ContactTrackingService getContactTrackingService() { if (_contactTrackingService == null) { synchronized (CCApi2.class) { if (_contactTrackingService == null) { _contactTrackingService = _retrofit.create(ContactTrackingService.class); } } } return _contactTrackingService; }
[ "public", "ContactTrackingService", "getContactTrackingService", "(", ")", "{", "if", "(", "_contactTrackingService", "==", "null", ")", "{", "synchronized", "(", "CCApi2", ".", "class", ")", "{", "if", "(", "_contactTrackingService", "==", "null", ")", "{", "_contactTrackingService", "=", "_retrofit", ".", "create", "(", "ContactTrackingService", ".", "class", ")", ";", "}", "}", "}", "return", "_contactTrackingService", ";", "}" ]
Gets the contact tracking service. @return the contact tracking service
[ "Gets", "the", "contact", "tracking", "service", "." ]
08b176505b8c55073245f38a56d1d9e14a3ccb37
https://github.com/constantcontact/java-sdk/blob/08b176505b8c55073245f38a56d1d9e14a3ccb37/sdk-rx/src/main/java/com/constantcontact/v2/CCApi2.java#L176-L186
139,786
constantcontact/java-sdk
sdk-rx/src/main/java/com/constantcontact/v2/CCApi2.java
CCApi2.getBulkActivitiesService
public BulkActivitiesService getBulkActivitiesService() { if (_bulkActivitiesService == null) { synchronized (CCApi2.class) { if (_bulkActivitiesService == null) { _bulkActivitiesService = _retrofit.create(BulkActivitiesService.class); } } } return _bulkActivitiesService; }
java
public BulkActivitiesService getBulkActivitiesService() { if (_bulkActivitiesService == null) { synchronized (CCApi2.class) { if (_bulkActivitiesService == null) { _bulkActivitiesService = _retrofit.create(BulkActivitiesService.class); } } } return _bulkActivitiesService; }
[ "public", "BulkActivitiesService", "getBulkActivitiesService", "(", ")", "{", "if", "(", "_bulkActivitiesService", "==", "null", ")", "{", "synchronized", "(", "CCApi2", ".", "class", ")", "{", "if", "(", "_bulkActivitiesService", "==", "null", ")", "{", "_bulkActivitiesService", "=", "_retrofit", ".", "create", "(", "BulkActivitiesService", ".", "class", ")", ";", "}", "}", "}", "return", "_bulkActivitiesService", ";", "}" ]
Gets the bulk activities service. @return the bulk activities service
[ "Gets", "the", "bulk", "activities", "service", "." ]
08b176505b8c55073245f38a56d1d9e14a3ccb37
https://github.com/constantcontact/java-sdk/blob/08b176505b8c55073245f38a56d1d9e14a3ccb37/sdk-rx/src/main/java/com/constantcontact/v2/CCApi2.java#L193-L203
139,787
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/metadata/TableMgr.java
TableMgr.createTable
public void createTable(String tblName, Schema sch, Transaction tx) { if (tblName != TCAT_TBLNAME && tblName != FCAT_TBLNAME) formatFileHeader(tblName, tx); // Optimization: store the ti tiMap.put(tblName, new TableInfo(tblName, sch)); // insert one record into tblcat RecordFile tcatfile = tcatInfo.open(tx, true); tcatfile.insert(); tcatfile.setVal(TCAT_TBLNAME, new VarcharConstant(tblName)); tcatfile.close(); // insert a record into fldcat for each field RecordFile fcatfile = fcatInfo.open(tx, true); for (String fldname : sch.fields()) { fcatfile.insert(); fcatfile.setVal(FCAT_TBLNAME, new VarcharConstant(tblName)); fcatfile.setVal(FCAT_FLDNAME, new VarcharConstant(fldname)); fcatfile.setVal(FCAT_TYPE, new IntegerConstant(sch.type(fldname) .getSqlType())); fcatfile.setVal(FCAT_TYPEARG, new IntegerConstant(sch.type(fldname) .getArgument())); } fcatfile.close(); }
java
public void createTable(String tblName, Schema sch, Transaction tx) { if (tblName != TCAT_TBLNAME && tblName != FCAT_TBLNAME) formatFileHeader(tblName, tx); // Optimization: store the ti tiMap.put(tblName, new TableInfo(tblName, sch)); // insert one record into tblcat RecordFile tcatfile = tcatInfo.open(tx, true); tcatfile.insert(); tcatfile.setVal(TCAT_TBLNAME, new VarcharConstant(tblName)); tcatfile.close(); // insert a record into fldcat for each field RecordFile fcatfile = fcatInfo.open(tx, true); for (String fldname : sch.fields()) { fcatfile.insert(); fcatfile.setVal(FCAT_TBLNAME, new VarcharConstant(tblName)); fcatfile.setVal(FCAT_FLDNAME, new VarcharConstant(fldname)); fcatfile.setVal(FCAT_TYPE, new IntegerConstant(sch.type(fldname) .getSqlType())); fcatfile.setVal(FCAT_TYPEARG, new IntegerConstant(sch.type(fldname) .getArgument())); } fcatfile.close(); }
[ "public", "void", "createTable", "(", "String", "tblName", ",", "Schema", "sch", ",", "Transaction", "tx", ")", "{", "if", "(", "tblName", "!=", "TCAT_TBLNAME", "&&", "tblName", "!=", "FCAT_TBLNAME", ")", "formatFileHeader", "(", "tblName", ",", "tx", ")", ";", "// Optimization: store the ti\r", "tiMap", ".", "put", "(", "tblName", ",", "new", "TableInfo", "(", "tblName", ",", "sch", ")", ")", ";", "// insert one record into tblcat\r", "RecordFile", "tcatfile", "=", "tcatInfo", ".", "open", "(", "tx", ",", "true", ")", ";", "tcatfile", ".", "insert", "(", ")", ";", "tcatfile", ".", "setVal", "(", "TCAT_TBLNAME", ",", "new", "VarcharConstant", "(", "tblName", ")", ")", ";", "tcatfile", ".", "close", "(", ")", ";", "// insert a record into fldcat for each field\r", "RecordFile", "fcatfile", "=", "fcatInfo", ".", "open", "(", "tx", ",", "true", ")", ";", "for", "(", "String", "fldname", ":", "sch", ".", "fields", "(", ")", ")", "{", "fcatfile", ".", "insert", "(", ")", ";", "fcatfile", ".", "setVal", "(", "FCAT_TBLNAME", ",", "new", "VarcharConstant", "(", "tblName", ")", ")", ";", "fcatfile", ".", "setVal", "(", "FCAT_FLDNAME", ",", "new", "VarcharConstant", "(", "fldname", ")", ")", ";", "fcatfile", ".", "setVal", "(", "FCAT_TYPE", ",", "new", "IntegerConstant", "(", "sch", ".", "type", "(", "fldname", ")", ".", "getSqlType", "(", ")", ")", ")", ";", "fcatfile", ".", "setVal", "(", "FCAT_TYPEARG", ",", "new", "IntegerConstant", "(", "sch", ".", "type", "(", "fldname", ")", ".", "getArgument", "(", ")", ")", ")", ";", "}", "fcatfile", ".", "close", "(", ")", ";", "}" ]
Creates a new table having the specified name and schema. @param tblName the name of the new table @param sch the table's schema @param tx the transaction creating the table
[ "Creates", "a", "new", "table", "having", "the", "specified", "name", "and", "schema", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/metadata/TableMgr.java#L121-L145
139,788
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/metadata/TableMgr.java
TableMgr.dropTable
public void dropTable(String tblName, Transaction tx) { // Remove the file RecordFile rf = getTableInfo(tblName, tx).open(tx, true); rf.remove(); // Optimization: remove from the TableInfo map tiMap.remove(tblName); // remove the record from tblcat RecordFile tcatfile = tcatInfo.open(tx, true); tcatfile.beforeFirst(); while (tcatfile.next()) { if (tcatfile.getVal(TCAT_TBLNAME).equals(new VarcharConstant(tblName))) { tcatfile.delete(); break; } } tcatfile.close(); // remove all records whose field FCAT_TBLNAME equals to tblName from fldcat RecordFile fcatfile = fcatInfo.open(tx, true); fcatfile.beforeFirst(); while (fcatfile.next()) { if (fcatfile.getVal(FCAT_TBLNAME).equals(new VarcharConstant(tblName))) fcatfile.delete(); } fcatfile.close(); // remove corresponding indices List<IndexInfo> allIndexes = new LinkedList<IndexInfo>(); Set<String> indexedFlds = VanillaDb.catalogMgr().getIndexedFields(tblName, tx); for (String indexedFld : indexedFlds) { List<IndexInfo> iis = VanillaDb.catalogMgr().getIndexInfo(tblName, indexedFld, tx); allIndexes.addAll(iis); } for (IndexInfo ii : allIndexes) VanillaDb.catalogMgr().dropIndex(ii.indexName(), tx); // remove corresponding views Collection<String> vnames = VanillaDb.catalogMgr().getViewNamesByTable(tblName, tx); Iterator<String> vnameiter = vnames.iterator(); while (vnameiter.hasNext()) VanillaDb.catalogMgr().dropView(vnameiter.next(), tx); }
java
public void dropTable(String tblName, Transaction tx) { // Remove the file RecordFile rf = getTableInfo(tblName, tx).open(tx, true); rf.remove(); // Optimization: remove from the TableInfo map tiMap.remove(tblName); // remove the record from tblcat RecordFile tcatfile = tcatInfo.open(tx, true); tcatfile.beforeFirst(); while (tcatfile.next()) { if (tcatfile.getVal(TCAT_TBLNAME).equals(new VarcharConstant(tblName))) { tcatfile.delete(); break; } } tcatfile.close(); // remove all records whose field FCAT_TBLNAME equals to tblName from fldcat RecordFile fcatfile = fcatInfo.open(tx, true); fcatfile.beforeFirst(); while (fcatfile.next()) { if (fcatfile.getVal(FCAT_TBLNAME).equals(new VarcharConstant(tblName))) fcatfile.delete(); } fcatfile.close(); // remove corresponding indices List<IndexInfo> allIndexes = new LinkedList<IndexInfo>(); Set<String> indexedFlds = VanillaDb.catalogMgr().getIndexedFields(tblName, tx); for (String indexedFld : indexedFlds) { List<IndexInfo> iis = VanillaDb.catalogMgr().getIndexInfo(tblName, indexedFld, tx); allIndexes.addAll(iis); } for (IndexInfo ii : allIndexes) VanillaDb.catalogMgr().dropIndex(ii.indexName(), tx); // remove corresponding views Collection<String> vnames = VanillaDb.catalogMgr().getViewNamesByTable(tblName, tx); Iterator<String> vnameiter = vnames.iterator(); while (vnameiter.hasNext()) VanillaDb.catalogMgr().dropView(vnameiter.next(), tx); }
[ "public", "void", "dropTable", "(", "String", "tblName", ",", "Transaction", "tx", ")", "{", "// Remove the file\r", "RecordFile", "rf", "=", "getTableInfo", "(", "tblName", ",", "tx", ")", ".", "open", "(", "tx", ",", "true", ")", ";", "rf", ".", "remove", "(", ")", ";", "// Optimization: remove from the TableInfo map\r", "tiMap", ".", "remove", "(", "tblName", ")", ";", "// remove the record from tblcat\r", "RecordFile", "tcatfile", "=", "tcatInfo", ".", "open", "(", "tx", ",", "true", ")", ";", "tcatfile", ".", "beforeFirst", "(", ")", ";", "while", "(", "tcatfile", ".", "next", "(", ")", ")", "{", "if", "(", "tcatfile", ".", "getVal", "(", "TCAT_TBLNAME", ")", ".", "equals", "(", "new", "VarcharConstant", "(", "tblName", ")", ")", ")", "{", "tcatfile", ".", "delete", "(", ")", ";", "break", ";", "}", "}", "tcatfile", ".", "close", "(", ")", ";", "// remove all records whose field FCAT_TBLNAME equals to tblName from fldcat\r", "RecordFile", "fcatfile", "=", "fcatInfo", ".", "open", "(", "tx", ",", "true", ")", ";", "fcatfile", ".", "beforeFirst", "(", ")", ";", "while", "(", "fcatfile", ".", "next", "(", ")", ")", "{", "if", "(", "fcatfile", ".", "getVal", "(", "FCAT_TBLNAME", ")", ".", "equals", "(", "new", "VarcharConstant", "(", "tblName", ")", ")", ")", "fcatfile", ".", "delete", "(", ")", ";", "}", "fcatfile", ".", "close", "(", ")", ";", "// remove corresponding indices\r", "List", "<", "IndexInfo", ">", "allIndexes", "=", "new", "LinkedList", "<", "IndexInfo", ">", "(", ")", ";", "Set", "<", "String", ">", "indexedFlds", "=", "VanillaDb", ".", "catalogMgr", "(", ")", ".", "getIndexedFields", "(", "tblName", ",", "tx", ")", ";", "for", "(", "String", "indexedFld", ":", "indexedFlds", ")", "{", "List", "<", "IndexInfo", ">", "iis", "=", "VanillaDb", ".", "catalogMgr", "(", ")", ".", "getIndexInfo", "(", "tblName", ",", "indexedFld", ",", "tx", ")", ";", "allIndexes", ".", "addAll", "(", "iis", ")", ";", "}", "for", "(", "IndexInfo", "ii", ":", "allIndexes", ")", "VanillaDb", ".", "catalogMgr", "(", ")", ".", "dropIndex", "(", "ii", ".", "indexName", "(", ")", ",", "tx", ")", ";", "// remove corresponding views\r", "Collection", "<", "String", ">", "vnames", "=", "VanillaDb", ".", "catalogMgr", "(", ")", ".", "getViewNamesByTable", "(", "tblName", ",", "tx", ")", ";", "Iterator", "<", "String", ">", "vnameiter", "=", "vnames", ".", "iterator", "(", ")", ";", "while", "(", "vnameiter", ".", "hasNext", "(", ")", ")", "VanillaDb", ".", "catalogMgr", "(", ")", ".", "dropView", "(", "vnameiter", ".", "next", "(", ")", ",", "tx", ")", ";", "}" ]
Remove a table with the specified name. @param tblName the name of the new table @param tx the transaction creating the table
[ "Remove", "a", "table", "with", "the", "specified", "name", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/metadata/TableMgr.java#L155-L200
139,789
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/metadata/TableMgr.java
TableMgr.getTableInfo
public TableInfo getTableInfo(String tblName, Transaction tx) { // Optimization: TableInfo resultTi = tiMap.get(tblName); if (resultTi != null) return resultTi; RecordFile tcatfile = tcatInfo.open(tx, true); tcatfile.beforeFirst(); boolean found = false; while (tcatfile.next()) { String t = (String) tcatfile.getVal(TCAT_TBLNAME).asJavaVal(); if (t.equals(tblName)) { found = true; break; } } tcatfile.close(); // return null if table is undefined if (!found) return null; RecordFile fcatfile = fcatInfo.open(tx, true); fcatfile.beforeFirst(); Schema sch = new Schema(); while (fcatfile.next()) if (((String) fcatfile.getVal(FCAT_TBLNAME).asJavaVal()) .equals(tblName)) { String fldname = (String) fcatfile.getVal(FCAT_FLDNAME) .asJavaVal(); int fldtype = (Integer) fcatfile.getVal(FCAT_TYPE).asJavaVal(); int fldarg = (Integer) fcatfile.getVal(FCAT_TYPEARG) .asJavaVal(); sch.addField(fldname, Type.newInstance(fldtype, fldarg)); } fcatfile.close(); // Optimization: resultTi = new TableInfo(tblName, sch); tiMap.put(tblName, resultTi); return resultTi; }
java
public TableInfo getTableInfo(String tblName, Transaction tx) { // Optimization: TableInfo resultTi = tiMap.get(tblName); if (resultTi != null) return resultTi; RecordFile tcatfile = tcatInfo.open(tx, true); tcatfile.beforeFirst(); boolean found = false; while (tcatfile.next()) { String t = (String) tcatfile.getVal(TCAT_TBLNAME).asJavaVal(); if (t.equals(tblName)) { found = true; break; } } tcatfile.close(); // return null if table is undefined if (!found) return null; RecordFile fcatfile = fcatInfo.open(tx, true); fcatfile.beforeFirst(); Schema sch = new Schema(); while (fcatfile.next()) if (((String) fcatfile.getVal(FCAT_TBLNAME).asJavaVal()) .equals(tblName)) { String fldname = (String) fcatfile.getVal(FCAT_FLDNAME) .asJavaVal(); int fldtype = (Integer) fcatfile.getVal(FCAT_TYPE).asJavaVal(); int fldarg = (Integer) fcatfile.getVal(FCAT_TYPEARG) .asJavaVal(); sch.addField(fldname, Type.newInstance(fldtype, fldarg)); } fcatfile.close(); // Optimization: resultTi = new TableInfo(tblName, sch); tiMap.put(tblName, resultTi); return resultTi; }
[ "public", "TableInfo", "getTableInfo", "(", "String", "tblName", ",", "Transaction", "tx", ")", "{", "// Optimization:\r", "TableInfo", "resultTi", "=", "tiMap", ".", "get", "(", "tblName", ")", ";", "if", "(", "resultTi", "!=", "null", ")", "return", "resultTi", ";", "RecordFile", "tcatfile", "=", "tcatInfo", ".", "open", "(", "tx", ",", "true", ")", ";", "tcatfile", ".", "beforeFirst", "(", ")", ";", "boolean", "found", "=", "false", ";", "while", "(", "tcatfile", ".", "next", "(", ")", ")", "{", "String", "t", "=", "(", "String", ")", "tcatfile", ".", "getVal", "(", "TCAT_TBLNAME", ")", ".", "asJavaVal", "(", ")", ";", "if", "(", "t", ".", "equals", "(", "tblName", ")", ")", "{", "found", "=", "true", ";", "break", ";", "}", "}", "tcatfile", ".", "close", "(", ")", ";", "// return null if table is undefined\r", "if", "(", "!", "found", ")", "return", "null", ";", "RecordFile", "fcatfile", "=", "fcatInfo", ".", "open", "(", "tx", ",", "true", ")", ";", "fcatfile", ".", "beforeFirst", "(", ")", ";", "Schema", "sch", "=", "new", "Schema", "(", ")", ";", "while", "(", "fcatfile", ".", "next", "(", ")", ")", "if", "(", "(", "(", "String", ")", "fcatfile", ".", "getVal", "(", "FCAT_TBLNAME", ")", ".", "asJavaVal", "(", ")", ")", ".", "equals", "(", "tblName", ")", ")", "{", "String", "fldname", "=", "(", "String", ")", "fcatfile", ".", "getVal", "(", "FCAT_FLDNAME", ")", ".", "asJavaVal", "(", ")", ";", "int", "fldtype", "=", "(", "Integer", ")", "fcatfile", ".", "getVal", "(", "FCAT_TYPE", ")", ".", "asJavaVal", "(", ")", ";", "int", "fldarg", "=", "(", "Integer", ")", "fcatfile", ".", "getVal", "(", "FCAT_TYPEARG", ")", ".", "asJavaVal", "(", ")", ";", "sch", ".", "addField", "(", "fldname", ",", "Type", ".", "newInstance", "(", "fldtype", ",", "fldarg", ")", ")", ";", "}", "fcatfile", ".", "close", "(", ")", ";", "// Optimization:\r", "resultTi", "=", "new", "TableInfo", "(", "tblName", ",", "sch", ")", ";", "tiMap", ".", "put", "(", "tblName", ",", "resultTi", ")", ";", "return", "resultTi", ";", "}" ]
Retrieves the metadata for the specified table out of the catalog. @param tblName the name of the table @param tx the transaction @return the table's stored metadata
[ "Retrieves", "the", "metadata", "for", "the", "specified", "table", "out", "of", "the", "catalog", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/metadata/TableMgr.java#L211-L250
139,790
vanilladb/vanillacore
src/main/java/org/vanilladb/core/remote/storedprocedure/SpStartUp.java
SpStartUp.startUp
public static void startUp(int port) throws Exception { // create a registry specific for the server on the default port Registry reg = LocateRegistry.createRegistry(port); // and post the server entry in it RemoteDriver d = new RemoteDriverImpl(); reg.rebind("vanilladb-sp", d); }
java
public static void startUp(int port) throws Exception { // create a registry specific for the server on the default port Registry reg = LocateRegistry.createRegistry(port); // and post the server entry in it RemoteDriver d = new RemoteDriverImpl(); reg.rebind("vanilladb-sp", d); }
[ "public", "static", "void", "startUp", "(", "int", "port", ")", "throws", "Exception", "{", "// create a registry specific for the server on the default port\r", "Registry", "reg", "=", "LocateRegistry", ".", "createRegistry", "(", "port", ")", ";", "// and post the server entry in it\r", "RemoteDriver", "d", "=", "new", "RemoteDriverImpl", "(", ")", ";", "reg", ".", "rebind", "(", "\"vanilladb-sp\"", ",", "d", ")", ";", "}" ]
Starts up the stored procedure call driver in server side by binding the remote driver object to local registry. @param port the network port for the server @throws Exception if the registry could not be exported
[ "Starts", "up", "the", "stored", "procedure", "call", "driver", "in", "server", "side", "by", "binding", "the", "remote", "driver", "object", "to", "local", "registry", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/remote/storedprocedure/SpStartUp.java#L31-L38
139,791
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/materialize/SortPlan.java
SortPlan.open
@Override public Scan open() { Scan src = p.open(); List<TempTable> runs = splitIntoRuns(src); /* * If the input source scan has no record, the temp table list will * result in size 0. Need to check the size of "runs" here. */ if (runs.size() == 0) return src; src.close(); while (runs.size() > 2) runs = doAMergeIteration(runs); return new SortScan(runs, comp); }
java
@Override public Scan open() { Scan src = p.open(); List<TempTable> runs = splitIntoRuns(src); /* * If the input source scan has no record, the temp table list will * result in size 0. Need to check the size of "runs" here. */ if (runs.size() == 0) return src; src.close(); while (runs.size() > 2) runs = doAMergeIteration(runs); return new SortScan(runs, comp); }
[ "@", "Override", "public", "Scan", "open", "(", ")", "{", "Scan", "src", "=", "p", ".", "open", "(", ")", ";", "List", "<", "TempTable", ">", "runs", "=", "splitIntoRuns", "(", "src", ")", ";", "/*\r\n\t\t * If the input source scan has no record, the temp table list will\r\n\t\t * result in size 0. Need to check the size of \"runs\" here.\r\n\t\t */", "if", "(", "runs", ".", "size", "(", ")", "==", "0", ")", "return", "src", ";", "src", ".", "close", "(", ")", ";", "while", "(", "runs", ".", "size", "(", ")", ">", "2", ")", "runs", "=", "doAMergeIteration", "(", "runs", ")", ";", "return", "new", "SortScan", "(", "runs", ",", "comp", ")", ";", "}" ]
This method is where most of the action is. Up to 2 sorted temporary tables are created, and are passed into SortScan for final merging. @see Plan#open()
[ "This", "method", "is", "where", "most", "of", "the", "action", "is", ".", "Up", "to", "2", "sorted", "temporary", "tables", "are", "created", "and", "are", "passed", "into", "SortScan", "for", "final", "merging", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/materialize/SortPlan.java#L88-L102
139,792
vanilladb/vanillacore
src/main/java/org/vanilladb/core/query/algebra/ProductScan.java
ProductScan.next
@Override public boolean next() { if (isLhsEmpty) return false; if (s2.next()) return true; else if (!(isLhsEmpty = !s1.next())) { s2.beforeFirst(); return s2.next(); } else { return false; } }
java
@Override public boolean next() { if (isLhsEmpty) return false; if (s2.next()) return true; else if (!(isLhsEmpty = !s1.next())) { s2.beforeFirst(); return s2.next(); } else { return false; } }
[ "@", "Override", "public", "boolean", "next", "(", ")", "{", "if", "(", "isLhsEmpty", ")", "return", "false", ";", "if", "(", "s2", ".", "next", "(", ")", ")", "return", "true", ";", "else", "if", "(", "!", "(", "isLhsEmpty", "=", "!", "s1", ".", "next", "(", ")", ")", ")", "{", "s2", ".", "beforeFirst", "(", ")", ";", "return", "s2", ".", "next", "(", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Moves the scan to the next record. The method moves to the next RHS record, if possible. Otherwise, it moves to the next LHS record and the first RHS record. If there are no more LHS records, the method returns false. @see Scan#next()
[ "Moves", "the", "scan", "to", "the", "next", "record", ".", "The", "method", "moves", "to", "the", "next", "RHS", "record", "if", "possible", ".", "Otherwise", "it", "moves", "to", "the", "next", "LHS", "record", "and", "the", "first", "RHS", "record", ".", "If", "there", "are", "no", "more", "LHS", "records", "the", "method", "returns", "false", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/query/algebra/ProductScan.java#L65-L77
139,793
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/tx/concurrency/LockTable.java
LockTable.sLock
void sLock(Object obj, long txNum) { Object anchor = getAnchor(obj); txWaitMap.put(txNum, anchor); synchronized (anchor) { Lockers lks = prepareLockers(obj); if (hasSLock(lks, txNum)) return; try { long timestamp = System.currentTimeMillis(); while (!sLockable(lks, txNum) && !waitingTooLong(timestamp)) { avoidDeadlock(lks, txNum, S_LOCK); lks.requestSet.add(txNum); anchor.wait(MAX_TIME); lks.requestSet.remove(txNum); } if (!sLockable(lks, txNum)) throw new LockAbortException(); lks.sLockers.add(txNum); getObjectSet(txNum).add(obj); } catch (InterruptedException e) { throw new LockAbortException("abort tx." + txNum + " by interrupted"); } } txWaitMap.remove(txNum); }
java
void sLock(Object obj, long txNum) { Object anchor = getAnchor(obj); txWaitMap.put(txNum, anchor); synchronized (anchor) { Lockers lks = prepareLockers(obj); if (hasSLock(lks, txNum)) return; try { long timestamp = System.currentTimeMillis(); while (!sLockable(lks, txNum) && !waitingTooLong(timestamp)) { avoidDeadlock(lks, txNum, S_LOCK); lks.requestSet.add(txNum); anchor.wait(MAX_TIME); lks.requestSet.remove(txNum); } if (!sLockable(lks, txNum)) throw new LockAbortException(); lks.sLockers.add(txNum); getObjectSet(txNum).add(obj); } catch (InterruptedException e) { throw new LockAbortException("abort tx." + txNum + " by interrupted"); } } txWaitMap.remove(txNum); }
[ "void", "sLock", "(", "Object", "obj", ",", "long", "txNum", ")", "{", "Object", "anchor", "=", "getAnchor", "(", "obj", ")", ";", "txWaitMap", ".", "put", "(", "txNum", ",", "anchor", ")", ";", "synchronized", "(", "anchor", ")", "{", "Lockers", "lks", "=", "prepareLockers", "(", "obj", ")", ";", "if", "(", "hasSLock", "(", "lks", ",", "txNum", ")", ")", "return", ";", "try", "{", "long", "timestamp", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "while", "(", "!", "sLockable", "(", "lks", ",", "txNum", ")", "&&", "!", "waitingTooLong", "(", "timestamp", ")", ")", "{", "avoidDeadlock", "(", "lks", ",", "txNum", ",", "S_LOCK", ")", ";", "lks", ".", "requestSet", ".", "add", "(", "txNum", ")", ";", "anchor", ".", "wait", "(", "MAX_TIME", ")", ";", "lks", ".", "requestSet", ".", "remove", "(", "txNum", ")", ";", "}", "if", "(", "!", "sLockable", "(", "lks", ",", "txNum", ")", ")", "throw", "new", "LockAbortException", "(", ")", ";", "lks", ".", "sLockers", ".", "add", "(", "txNum", ")", ";", "getObjectSet", "(", "txNum", ")", ".", "add", "(", "obj", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "LockAbortException", "(", "\"abort tx.\"", "+", "txNum", "+", "\" by interrupted\"", ")", ";", "}", "}", "txWaitMap", ".", "remove", "(", "txNum", ")", ";", "}" ]
Grants an slock on the specified item. If any conflict lock exists when the method is called, then the calling thread will be placed on a wait list until the lock is released. If the thread remains on the wait list for a certain amount of time, then an exception is thrown. @param obj a lockable item @param txNum a transaction number
[ "Grants", "an", "slock", "on", "the", "specified", "item", ".", "If", "any", "conflict", "lock", "exists", "when", "the", "method", "is", "called", "then", "the", "calling", "thread", "will", "be", "placed", "on", "a", "wait", "list", "until", "the", "lock", "is", "released", ".", "If", "the", "thread", "remains", "on", "the", "wait", "list", "for", "a", "certain", "amount", "of", "time", "then", "an", "exception", "is", "thrown", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/tx/concurrency/LockTable.java#L186-L213
139,794
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/tx/concurrency/LockTable.java
LockTable.xLock
void xLock(Object obj, long txNum) { Object anchor = getAnchor(obj); txWaitMap.put(txNum, anchor); synchronized (anchor) { Lockers lks = prepareLockers(obj); if (hasXLock(lks, txNum)) return; try { long timestamp = System.currentTimeMillis(); while (!xLockable(lks, txNum) && !waitingTooLong(timestamp)) { avoidDeadlock(lks, txNum, X_LOCK); lks.requestSet.add(txNum); anchor.wait(MAX_TIME); lks.requestSet.remove(txNum); } if (!xLockable(lks, txNum)) throw new LockAbortException(); lks.xLocker = txNum; getObjectSet(txNum).add(obj); } catch (InterruptedException e) { throw new LockAbortException(); } } txWaitMap.remove(txNum); }
java
void xLock(Object obj, long txNum) { Object anchor = getAnchor(obj); txWaitMap.put(txNum, anchor); synchronized (anchor) { Lockers lks = prepareLockers(obj); if (hasXLock(lks, txNum)) return; try { long timestamp = System.currentTimeMillis(); while (!xLockable(lks, txNum) && !waitingTooLong(timestamp)) { avoidDeadlock(lks, txNum, X_LOCK); lks.requestSet.add(txNum); anchor.wait(MAX_TIME); lks.requestSet.remove(txNum); } if (!xLockable(lks, txNum)) throw new LockAbortException(); lks.xLocker = txNum; getObjectSet(txNum).add(obj); } catch (InterruptedException e) { throw new LockAbortException(); } } txWaitMap.remove(txNum); }
[ "void", "xLock", "(", "Object", "obj", ",", "long", "txNum", ")", "{", "Object", "anchor", "=", "getAnchor", "(", "obj", ")", ";", "txWaitMap", ".", "put", "(", "txNum", ",", "anchor", ")", ";", "synchronized", "(", "anchor", ")", "{", "Lockers", "lks", "=", "prepareLockers", "(", "obj", ")", ";", "if", "(", "hasXLock", "(", "lks", ",", "txNum", ")", ")", "return", ";", "try", "{", "long", "timestamp", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "while", "(", "!", "xLockable", "(", "lks", ",", "txNum", ")", "&&", "!", "waitingTooLong", "(", "timestamp", ")", ")", "{", "avoidDeadlock", "(", "lks", ",", "txNum", ",", "X_LOCK", ")", ";", "lks", ".", "requestSet", ".", "add", "(", "txNum", ")", ";", "anchor", ".", "wait", "(", "MAX_TIME", ")", ";", "lks", ".", "requestSet", ".", "remove", "(", "txNum", ")", ";", "}", "if", "(", "!", "xLockable", "(", "lks", ",", "txNum", ")", ")", "throw", "new", "LockAbortException", "(", ")", ";", "lks", ".", "xLocker", "=", "txNum", ";", "getObjectSet", "(", "txNum", ")", ".", "add", "(", "obj", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "LockAbortException", "(", ")", ";", "}", "}", "txWaitMap", ".", "remove", "(", "txNum", ")", ";", "}" ]
Grants an xlock on the specified item. If any conflict lock exists when the method is called, then the calling thread will be placed on a wait list until the lock is released. If the thread remains on the wait list for a certain amount of time, then an exception is thrown. @param obj a lockable item @param txNum a transaction number
[ "Grants", "an", "xlock", "on", "the", "specified", "item", ".", "If", "any", "conflict", "lock", "exists", "when", "the", "method", "is", "called", "then", "the", "calling", "thread", "will", "be", "placed", "on", "a", "wait", "list", "until", "the", "lock", "is", "released", ".", "If", "the", "thread", "remains", "on", "the", "wait", "list", "for", "a", "certain", "amount", "of", "time", "then", "an", "exception", "is", "thrown", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/tx/concurrency/LockTable.java#L227-L254
139,795
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/tx/concurrency/LockTable.java
LockTable.sixLock
void sixLock(Object obj, long txNum) { Object anchor = getAnchor(obj); txWaitMap.put(txNum, anchor); synchronized (anchor) { Lockers lks = prepareLockers(obj); if (hasSixLock(lks, txNum)) return; try { long timestamp = System.currentTimeMillis(); while (!sixLockable(lks, txNum) && !waitingTooLong(timestamp)) { avoidDeadlock(lks, txNum, SIX_LOCK); lks.requestSet.add(txNum); anchor.wait(MAX_TIME); lks.requestSet.remove(txNum); } if (!sixLockable(lks, txNum)) throw new LockAbortException(); lks.sixLocker = txNum; getObjectSet(txNum).add(obj); } catch (InterruptedException e) { throw new LockAbortException(); } } txWaitMap.remove(txNum); }
java
void sixLock(Object obj, long txNum) { Object anchor = getAnchor(obj); txWaitMap.put(txNum, anchor); synchronized (anchor) { Lockers lks = prepareLockers(obj); if (hasSixLock(lks, txNum)) return; try { long timestamp = System.currentTimeMillis(); while (!sixLockable(lks, txNum) && !waitingTooLong(timestamp)) { avoidDeadlock(lks, txNum, SIX_LOCK); lks.requestSet.add(txNum); anchor.wait(MAX_TIME); lks.requestSet.remove(txNum); } if (!sixLockable(lks, txNum)) throw new LockAbortException(); lks.sixLocker = txNum; getObjectSet(txNum).add(obj); } catch (InterruptedException e) { throw new LockAbortException(); } } txWaitMap.remove(txNum); }
[ "void", "sixLock", "(", "Object", "obj", ",", "long", "txNum", ")", "{", "Object", "anchor", "=", "getAnchor", "(", "obj", ")", ";", "txWaitMap", ".", "put", "(", "txNum", ",", "anchor", ")", ";", "synchronized", "(", "anchor", ")", "{", "Lockers", "lks", "=", "prepareLockers", "(", "obj", ")", ";", "if", "(", "hasSixLock", "(", "lks", ",", "txNum", ")", ")", "return", ";", "try", "{", "long", "timestamp", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "while", "(", "!", "sixLockable", "(", "lks", ",", "txNum", ")", "&&", "!", "waitingTooLong", "(", "timestamp", ")", ")", "{", "avoidDeadlock", "(", "lks", ",", "txNum", ",", "SIX_LOCK", ")", ";", "lks", ".", "requestSet", ".", "add", "(", "txNum", ")", ";", "anchor", ".", "wait", "(", "MAX_TIME", ")", ";", "lks", ".", "requestSet", ".", "remove", "(", "txNum", ")", ";", "}", "if", "(", "!", "sixLockable", "(", "lks", ",", "txNum", ")", ")", "throw", "new", "LockAbortException", "(", ")", ";", "lks", ".", "sixLocker", "=", "txNum", ";", "getObjectSet", "(", "txNum", ")", ".", "add", "(", "obj", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "LockAbortException", "(", ")", ";", "}", "}", "txWaitMap", ".", "remove", "(", "txNum", ")", ";", "}" ]
Grants an sixlock on the specified item. If any conflict lock exists when the method is called, then the calling thread will be placed on a wait list until the lock is released. If the thread remains on the wait list for a certain amount of time, then an exception is thrown. @param obj a lockable item @param txNum a transaction number
[ "Grants", "an", "sixlock", "on", "the", "specified", "item", ".", "If", "any", "conflict", "lock", "exists", "when", "the", "method", "is", "called", "then", "the", "calling", "thread", "will", "be", "placed", "on", "a", "wait", "list", "until", "the", "lock", "is", "released", ".", "If", "the", "thread", "remains", "on", "the", "wait", "list", "for", "a", "certain", "amount", "of", "time", "then", "an", "exception", "is", "thrown", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/tx/concurrency/LockTable.java#L268-L295
139,796
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/tx/concurrency/LockTable.java
LockTable.isLock
void isLock(Object obj, long txNum) { Object anchor = getAnchor(obj); txWaitMap.put(txNum, anchor); synchronized (anchor) { Lockers lks = prepareLockers(obj); if (hasIsLock(lks, txNum)) return; try { long timestamp = System.currentTimeMillis(); while (!isLockable(lks, txNum) && !waitingTooLong(timestamp)) { avoidDeadlock(lks, txNum, IS_LOCK); lks.requestSet.add(txNum); anchor.wait(MAX_TIME); lks.requestSet.remove(txNum); } if (!isLockable(lks, txNum)) throw new LockAbortException(); lks.isLockers.add(txNum); getObjectSet(txNum).add(obj); } catch (InterruptedException e) { throw new LockAbortException(); } } txWaitMap.remove(txNum); }
java
void isLock(Object obj, long txNum) { Object anchor = getAnchor(obj); txWaitMap.put(txNum, anchor); synchronized (anchor) { Lockers lks = prepareLockers(obj); if (hasIsLock(lks, txNum)) return; try { long timestamp = System.currentTimeMillis(); while (!isLockable(lks, txNum) && !waitingTooLong(timestamp)) { avoidDeadlock(lks, txNum, IS_LOCK); lks.requestSet.add(txNum); anchor.wait(MAX_TIME); lks.requestSet.remove(txNum); } if (!isLockable(lks, txNum)) throw new LockAbortException(); lks.isLockers.add(txNum); getObjectSet(txNum).add(obj); } catch (InterruptedException e) { throw new LockAbortException(); } } txWaitMap.remove(txNum); }
[ "void", "isLock", "(", "Object", "obj", ",", "long", "txNum", ")", "{", "Object", "anchor", "=", "getAnchor", "(", "obj", ")", ";", "txWaitMap", ".", "put", "(", "txNum", ",", "anchor", ")", ";", "synchronized", "(", "anchor", ")", "{", "Lockers", "lks", "=", "prepareLockers", "(", "obj", ")", ";", "if", "(", "hasIsLock", "(", "lks", ",", "txNum", ")", ")", "return", ";", "try", "{", "long", "timestamp", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "while", "(", "!", "isLockable", "(", "lks", ",", "txNum", ")", "&&", "!", "waitingTooLong", "(", "timestamp", ")", ")", "{", "avoidDeadlock", "(", "lks", ",", "txNum", ",", "IS_LOCK", ")", ";", "lks", ".", "requestSet", ".", "add", "(", "txNum", ")", ";", "anchor", ".", "wait", "(", "MAX_TIME", ")", ";", "lks", ".", "requestSet", ".", "remove", "(", "txNum", ")", ";", "}", "if", "(", "!", "isLockable", "(", "lks", ",", "txNum", ")", ")", "throw", "new", "LockAbortException", "(", ")", ";", "lks", ".", "isLockers", ".", "add", "(", "txNum", ")", ";", "getObjectSet", "(", "txNum", ")", ".", "add", "(", "obj", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "LockAbortException", "(", ")", ";", "}", "}", "txWaitMap", ".", "remove", "(", "txNum", ")", ";", "}" ]
Grants an islock on the specified item. If any conflict lock exists when the method is called, then the calling thread will be placed on a wait list until the lock is released. If the thread remains on the wait list for a certain amount of time, then an exception is thrown. @param obj a lockable item @param txNum a transaction number
[ "Grants", "an", "islock", "on", "the", "specified", "item", ".", "If", "any", "conflict", "lock", "exists", "when", "the", "method", "is", "called", "then", "the", "calling", "thread", "will", "be", "placed", "on", "a", "wait", "list", "until", "the", "lock", "is", "released", ".", "If", "the", "thread", "remains", "on", "the", "wait", "list", "for", "a", "certain", "amount", "of", "time", "then", "an", "exception", "is", "thrown", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/tx/concurrency/LockTable.java#L308-L333
139,797
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/tx/concurrency/LockTable.java
LockTable.ixLock
void ixLock(Object obj, long txNum) { Object anchor = getAnchor(obj); txWaitMap.put(txNum, anchor); synchronized (anchor) { Lockers lks = prepareLockers(obj); if (hasIxLock(lks, txNum)) return; try { long timestamp = System.currentTimeMillis(); while (!ixLockable(lks, txNum) && !waitingTooLong(timestamp)) { avoidDeadlock(lks, txNum, IX_LOCK); lks.requestSet.add(txNum); anchor.wait(MAX_TIME); lks.requestSet.remove(txNum); } if (!ixLockable(lks, txNum)) throw new LockAbortException(); lks.ixLockers.add(txNum); getObjectSet(txNum).add(obj); } catch (InterruptedException e) { throw new LockAbortException(); } } txWaitMap.remove(txNum); }
java
void ixLock(Object obj, long txNum) { Object anchor = getAnchor(obj); txWaitMap.put(txNum, anchor); synchronized (anchor) { Lockers lks = prepareLockers(obj); if (hasIxLock(lks, txNum)) return; try { long timestamp = System.currentTimeMillis(); while (!ixLockable(lks, txNum) && !waitingTooLong(timestamp)) { avoidDeadlock(lks, txNum, IX_LOCK); lks.requestSet.add(txNum); anchor.wait(MAX_TIME); lks.requestSet.remove(txNum); } if (!ixLockable(lks, txNum)) throw new LockAbortException(); lks.ixLockers.add(txNum); getObjectSet(txNum).add(obj); } catch (InterruptedException e) { throw new LockAbortException(); } } txWaitMap.remove(txNum); }
[ "void", "ixLock", "(", "Object", "obj", ",", "long", "txNum", ")", "{", "Object", "anchor", "=", "getAnchor", "(", "obj", ")", ";", "txWaitMap", ".", "put", "(", "txNum", ",", "anchor", ")", ";", "synchronized", "(", "anchor", ")", "{", "Lockers", "lks", "=", "prepareLockers", "(", "obj", ")", ";", "if", "(", "hasIxLock", "(", "lks", ",", "txNum", ")", ")", "return", ";", "try", "{", "long", "timestamp", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "while", "(", "!", "ixLockable", "(", "lks", ",", "txNum", ")", "&&", "!", "waitingTooLong", "(", "timestamp", ")", ")", "{", "avoidDeadlock", "(", "lks", ",", "txNum", ",", "IX_LOCK", ")", ";", "lks", ".", "requestSet", ".", "add", "(", "txNum", ")", ";", "anchor", ".", "wait", "(", "MAX_TIME", ")", ";", "lks", ".", "requestSet", ".", "remove", "(", "txNum", ")", ";", "}", "if", "(", "!", "ixLockable", "(", "lks", ",", "txNum", ")", ")", "throw", "new", "LockAbortException", "(", ")", ";", "lks", ".", "ixLockers", ".", "add", "(", "txNum", ")", ";", "getObjectSet", "(", "txNum", ")", ".", "add", "(", "obj", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "LockAbortException", "(", ")", ";", "}", "}", "txWaitMap", ".", "remove", "(", "txNum", ")", ";", "}" ]
Grants an ixlock on the specified item. If any conflict lock exists when the method is called, then the calling thread will be placed on a wait list until the lock is released. If the thread remains on the wait list for a certain amount of time, then an exception is thrown. @param obj a lockable item @param txNum a transaction number
[ "Grants", "an", "ixlock", "on", "the", "specified", "item", ".", "If", "any", "conflict", "lock", "exists", "when", "the", "method", "is", "called", "then", "the", "calling", "thread", "will", "be", "placed", "on", "a", "wait", "list", "until", "the", "lock", "is", "released", ".", "If", "the", "thread", "remains", "on", "the", "wait", "list", "for", "a", "certain", "amount", "of", "time", "then", "an", "exception", "is", "thrown", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/tx/concurrency/LockTable.java#L346-L373
139,798
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/tx/concurrency/LockTable.java
LockTable.release
void release(Object obj, long txNum, int lockType) { Object anchor = getAnchor(obj); synchronized (anchor) { Lockers lks = lockerMap.get(obj); /* * In some situation, tx will release the lock of the object that * have been released. */ if (lks != null) { releaseLock(lks, anchor, txNum, lockType); // Check if this transaction have any other lock on this object if (!hasSLock(lks, txNum) && !hasXLock(lks, txNum) && !hasSixLock(lks, txNum) && !hasIsLock(lks, txNum) && !hasIxLock(lks, txNum)) { getObjectSet(txNum).remove(obj); // Remove the locker, if there is no other transaction // having it if (!sLocked(lks) && !xLocked(lks) && !sixLocked(lks) && !isLocked(lks) && !ixLocked(lks) && lks.requestSet.isEmpty()) lockerMap.remove(obj); } } } }
java
void release(Object obj, long txNum, int lockType) { Object anchor = getAnchor(obj); synchronized (anchor) { Lockers lks = lockerMap.get(obj); /* * In some situation, tx will release the lock of the object that * have been released. */ if (lks != null) { releaseLock(lks, anchor, txNum, lockType); // Check if this transaction have any other lock on this object if (!hasSLock(lks, txNum) && !hasXLock(lks, txNum) && !hasSixLock(lks, txNum) && !hasIsLock(lks, txNum) && !hasIxLock(lks, txNum)) { getObjectSet(txNum).remove(obj); // Remove the locker, if there is no other transaction // having it if (!sLocked(lks) && !xLocked(lks) && !sixLocked(lks) && !isLocked(lks) && !ixLocked(lks) && lks.requestSet.isEmpty()) lockerMap.remove(obj); } } } }
[ "void", "release", "(", "Object", "obj", ",", "long", "txNum", ",", "int", "lockType", ")", "{", "Object", "anchor", "=", "getAnchor", "(", "obj", ")", ";", "synchronized", "(", "anchor", ")", "{", "Lockers", "lks", "=", "lockerMap", ".", "get", "(", "obj", ")", ";", "/*\r\n\t\t\t * In some situation, tx will release the lock of the object that\r\n\t\t\t * have been released.\r\n\t\t\t */", "if", "(", "lks", "!=", "null", ")", "{", "releaseLock", "(", "lks", ",", "anchor", ",", "txNum", ",", "lockType", ")", ";", "// Check if this transaction have any other lock on this object\r", "if", "(", "!", "hasSLock", "(", "lks", ",", "txNum", ")", "&&", "!", "hasXLock", "(", "lks", ",", "txNum", ")", "&&", "!", "hasSixLock", "(", "lks", ",", "txNum", ")", "&&", "!", "hasIsLock", "(", "lks", ",", "txNum", ")", "&&", "!", "hasIxLock", "(", "lks", ",", "txNum", ")", ")", "{", "getObjectSet", "(", "txNum", ")", ".", "remove", "(", "obj", ")", ";", "// Remove the locker, if there is no other transaction\r", "// having it\r", "if", "(", "!", "sLocked", "(", "lks", ")", "&&", "!", "xLocked", "(", "lks", ")", "&&", "!", "sixLocked", "(", "lks", ")", "&&", "!", "isLocked", "(", "lks", ")", "&&", "!", "ixLocked", "(", "lks", ")", "&&", "lks", ".", "requestSet", ".", "isEmpty", "(", ")", ")", "lockerMap", ".", "remove", "(", "obj", ")", ";", "}", "}", "}", "}" ]
Releases the specified type of lock on an item holding by a transaction. If a lock is the last lock on that block, then the waiting transactions are notified. @param obj a lockable item @param txNum a transaction number @param lockType the type of lock
[ "Releases", "the", "specified", "type", "of", "lock", "on", "an", "item", "holding", "by", "a", "transaction", ".", "If", "a", "lock", "is", "the", "last", "lock", "on", "that", "block", "then", "the", "waiting", "transactions", "are", "notified", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/tx/concurrency/LockTable.java#L387-L413
139,799
vanilladb/vanillacore
src/main/java/org/vanilladb/core/storage/tx/concurrency/LockTable.java
LockTable.releaseAll
void releaseAll(long txNum, boolean sLockOnly) { Set<Object> objectsToRelease = getObjectSet(txNum); for (Object obj : objectsToRelease) { Object anchor = getAnchor(obj); synchronized (anchor) { Lockers lks = lockerMap.get(obj); if (lks != null) { if (hasSLock(lks, txNum)) releaseLock(lks, anchor, txNum, S_LOCK); if (hasXLock(lks, txNum) && !sLockOnly) releaseLock(lks, anchor, txNum, X_LOCK); if (hasSixLock(lks, txNum)) releaseLock(lks, anchor, txNum, SIX_LOCK); while (hasIsLock(lks, txNum)) releaseLock(lks, anchor, txNum, IS_LOCK); while (hasIxLock(lks, txNum) && !sLockOnly) releaseLock(lks, anchor, txNum, IX_LOCK); // Remove the locker, if there is no other transaction // having it if (!sLocked(lks) && !xLocked(lks) && !sixLocked(lks) && !isLocked(lks) && !ixLocked(lks) && lks.requestSet.isEmpty()) lockerMap.remove(obj); } } } txWaitMap.remove(txNum); txnsToBeAborted.remove(txNum); lockByMap.remove(txNum); }
java
void releaseAll(long txNum, boolean sLockOnly) { Set<Object> objectsToRelease = getObjectSet(txNum); for (Object obj : objectsToRelease) { Object anchor = getAnchor(obj); synchronized (anchor) { Lockers lks = lockerMap.get(obj); if (lks != null) { if (hasSLock(lks, txNum)) releaseLock(lks, anchor, txNum, S_LOCK); if (hasXLock(lks, txNum) && !sLockOnly) releaseLock(lks, anchor, txNum, X_LOCK); if (hasSixLock(lks, txNum)) releaseLock(lks, anchor, txNum, SIX_LOCK); while (hasIsLock(lks, txNum)) releaseLock(lks, anchor, txNum, IS_LOCK); while (hasIxLock(lks, txNum) && !sLockOnly) releaseLock(lks, anchor, txNum, IX_LOCK); // Remove the locker, if there is no other transaction // having it if (!sLocked(lks) && !xLocked(lks) && !sixLocked(lks) && !isLocked(lks) && !ixLocked(lks) && lks.requestSet.isEmpty()) lockerMap.remove(obj); } } } txWaitMap.remove(txNum); txnsToBeAborted.remove(txNum); lockByMap.remove(txNum); }
[ "void", "releaseAll", "(", "long", "txNum", ",", "boolean", "sLockOnly", ")", "{", "Set", "<", "Object", ">", "objectsToRelease", "=", "getObjectSet", "(", "txNum", ")", ";", "for", "(", "Object", "obj", ":", "objectsToRelease", ")", "{", "Object", "anchor", "=", "getAnchor", "(", "obj", ")", ";", "synchronized", "(", "anchor", ")", "{", "Lockers", "lks", "=", "lockerMap", ".", "get", "(", "obj", ")", ";", "if", "(", "lks", "!=", "null", ")", "{", "if", "(", "hasSLock", "(", "lks", ",", "txNum", ")", ")", "releaseLock", "(", "lks", ",", "anchor", ",", "txNum", ",", "S_LOCK", ")", ";", "if", "(", "hasXLock", "(", "lks", ",", "txNum", ")", "&&", "!", "sLockOnly", ")", "releaseLock", "(", "lks", ",", "anchor", ",", "txNum", ",", "X_LOCK", ")", ";", "if", "(", "hasSixLock", "(", "lks", ",", "txNum", ")", ")", "releaseLock", "(", "lks", ",", "anchor", ",", "txNum", ",", "SIX_LOCK", ")", ";", "while", "(", "hasIsLock", "(", "lks", ",", "txNum", ")", ")", "releaseLock", "(", "lks", ",", "anchor", ",", "txNum", ",", "IS_LOCK", ")", ";", "while", "(", "hasIxLock", "(", "lks", ",", "txNum", ")", "&&", "!", "sLockOnly", ")", "releaseLock", "(", "lks", ",", "anchor", ",", "txNum", ",", "IX_LOCK", ")", ";", "// Remove the locker, if there is no other transaction\r", "// having it\r", "if", "(", "!", "sLocked", "(", "lks", ")", "&&", "!", "xLocked", "(", "lks", ")", "&&", "!", "sixLocked", "(", "lks", ")", "&&", "!", "isLocked", "(", "lks", ")", "&&", "!", "ixLocked", "(", "lks", ")", "&&", "lks", ".", "requestSet", ".", "isEmpty", "(", ")", ")", "lockerMap", ".", "remove", "(", "obj", ")", ";", "}", "}", "}", "txWaitMap", ".", "remove", "(", "txNum", ")", ";", "txnsToBeAborted", ".", "remove", "(", "txNum", ")", ";", "lockByMap", ".", "remove", "(", "txNum", ")", ";", "}" ]
Releases all locks held by a transaction. If a lock is the last lock on that block, then the waiting transactions are notified. @param txNum a transaction number @param sLockOnly release slocks only
[ "Releases", "all", "locks", "held", "by", "a", "transaction", ".", "If", "a", "lock", "is", "the", "last", "lock", "on", "that", "block", "then", "the", "waiting", "transactions", "are", "notified", "." ]
d9a34e876b1b83226036d1fa982a614bbef59bd1
https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/tx/concurrency/LockTable.java#L425-L461