use of org.rajawali3d.examples.data.Example in project Rajawali by Rajawali.
the class ExamplesActivity method processExtras.
private void processExtras(Bundle extras) {
Example example = extras.getParcelable(EXTRA_EXAMPLE);
if (example == null) {
throw new NullPointerException();
}
Class aClass = example.getType();
try {
Bundle bundle = new Bundle();
bundle.putString(AExampleFragment.BUNDLE_EXAMPLE_URL, example.getPath());
Fragment fragment = (Fragment) aClass.newInstance();
fragment.setArguments(bundle);
getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, fragment, aClass.getName()).commit();
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
use of org.rajawali3d.examples.data.Example in project Rajawali by Rajawali.
the class CategoryAdapter method filter.
public void filter(@NonNull Context context, @NonNull String query) {
String queryLC = query.trim().toLowerCase(Locale.ENGLISH);
List<Category> categories = new LinkedList<>();
if (queryLC.length() == 0) {
categories.addAll(categoriesOriginal);
} else {
for (Category category : categoriesOriginal) {
List<Example> filtered = new LinkedList<>();
Example[] examples = category.getExamples();
// If the category matches the query, add all examples then move to the next item
String categoryName = context.getString(category.getName()).toLowerCase(Locale.ENGLISH);
if (categoryName.contains(queryLC)) {
categories.add(category);
continue;
}
// Iterate the examples adding matches to the filtered list
for (Example example : examples) {
String exampleName = context.getString(example.getName()).toLowerCase(Locale.ENGLISH);
if (exampleName.contains(queryLC)) {
filtered.add(example);
}
}
// If the category has any matching examples, keep it and add the matches
final int size = filtered.size();
if (size > 0) {
Example[] filteredExamples = filtered.toArray(new Example[size]);
Category filteredCategory = new Category(category.getName(), filteredExamples);
categories.add(filteredCategory);
}
}
}
setReferencesFromList(categories);
}
use of org.rajawali3d.examples.data.Example in project Rajawali by Rajawali.
the class CategoryAdapter method filterDone.
public boolean filterDone(@NonNull Context context) {
if (categoriesDisplayed.size() == 1) {
Category category = categoriesDisplayed.get(0);
Example[] examples = category.getExamples();
if (examples.length == 1) {
Example example = examples[0];
onExampleSelected(context, example);
return true;
}
}
return false;
}
use of org.rajawali3d.examples.data.Example in project Rajawali by Rajawali.
the class CategoryAdapter method onReferenceClicked.
@Override
public void onReferenceClicked(View view, IndexReference reference) {
Class type = reference.getType();
if (Example.class.equals(type)) {
Example example = (Example) reference.get();
Context context = view.getContext();
onExampleSelected(context, example);
} else {
throw new IllegalStateException("Unhandled reference for " + type);
}
}
use of org.rajawali3d.examples.data.Example in project Rajawali by Rajawali.
the class CategoryAdapter method setReferencesFromList.
void setReferencesFromList(List<Category> categories) {
final List<NamedIndexReference<INamed>> indexReferences;
indexReferences = new LinkedList<>();
for (Category category : categories) {
indexReferences.add(new CategoryReference(category));
Example[] examples = category.getExamples();
for (Example example : examples) {
indexReferences.add(new ExampleReference(example));
}
}
categoriesDisplayed = categories;
setReferences(indexReferences);
}
Aggregations