use of com.joanzapata.iconify.widget.IconImageView in project edx-app-android by edx.
the class FullScreenErrorNotification method showError.
/**
* Show the error notification as an overlay message on top of the content area, according to
* the provided details.
* <p>
* The root view will be determined by walking up the view tree to see if there is any view with
* the ID of {@link R.id#content_error R.id.content_error}. If one is found, then that would be
* used as the root. If not, then if the content view's parent is already a FrameLayout, then
* that would be used; otherwise a new one will be created, inserted as the new parent, and used
* as the root.
*
* @param errorMsg The error message.
* @param icon The error icon.
* @param actionTextResId The resource ID of the action button text.
* @param actionListener The callback to be invoked when the action button is clicked.
*/
public void showError(@NonNull final String errorMsg, @Nullable final Icon icon, @StringRes final int actionTextResId, @Nullable final View.OnClickListener actionListener) {
final ViewGroup root = findSuitableAncestorLayout();
if (root == null)
return;
final View layoutView = root.findViewById(R.id.content_error);
if (layoutView instanceof ViewGroup) {
errorLayout = (ViewGroup) layoutView;
} else {
final LayoutInflater layoutInflater = LayoutInflater.from(view.getContext());
errorLayout = (ViewGroup) layoutInflater.inflate(R.layout.content_error, root, false);
root.addView(errorLayout);
}
final TextView messageView = (TextView) errorLayout.findViewById(R.id.content_error_text);
final Button actionButton = (Button) errorLayout.findViewById(R.id.content_error_action);
final IconImageView iconView = (IconImageView) errorLayout.findViewById(R.id.content_error_icon);
messageView.setText(errorMsg);
if (icon == null) {
iconView.setVisibility(GONE);
} else {
iconView.setVisibility(VISIBLE);
iconView.setIcon(icon);
}
if (actionTextResId == 0 || actionListener == null) {
actionButton.setVisibility(GONE);
} else {
actionButton.setVisibility(VISIBLE);
actionButton.setText(actionTextResId);
actionButton.setOnClickListener(actionListener);
}
view.setVisibility(GONE);
errorLayout.setVisibility(VISIBLE);
}
use of com.joanzapata.iconify.widget.IconImageView in project edx-app-android by edx.
the class CourseDashboardActivityTest method assertRow.
/**
* Generic method for asserting the properties of the row views given a
* certain row layout and the expected properties.
*
* @param rowView The root {link View} of the row
* @param icon The Font Awesome icon key for the row
* @param titleRes The string resource id for the row title
* @param subtitleRes The string resource id for the row subtitle
*/
private void assertRow(View rowView, FontAwesomeIcons icon, int titleRes, int subtitleRes) {
assertNotNull(rowView);
assertThat(rowView).isInstanceOf(ViewGroup.class);
View iconView = rowView.findViewById(R.id.row_type);
assertNotNull(iconView);
assertThat(iconView).isInstanceOf(IconImageView.class);
assertEquals(icon, ((IconImageView) iconView).getIcon());
Resources res = rowView.getContext().getResources();
View titleView = rowView.findViewById(R.id.row_title);
assertNotNull(titleView);
assertThat(titleView).isInstanceOf(TextView.class);
assertThat((TextView) titleView).hasText(res.getText(titleRes));
View subtitleView = rowView.findViewById(R.id.row_subtitle);
assertNotNull(subtitleView);
assertThat(subtitleView).isInstanceOf(TextView.class);
assertThat((TextView) subtitleView).hasText(res.getText(subtitleRes));
}
use of com.joanzapata.iconify.widget.IconImageView in project edx-app-android by edx.
the class CourseOutlineFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final Bundle bundle = getArguments();
courseData = (EnrolledCoursesResponse) bundle.getSerializable(Router.EXTRA_COURSE_DATA);
courseComponentId = bundle.getString(Router.EXTRA_COURSE_COMPONENT_ID);
isVideoMode = bundle.getBoolean(Router.EXTRA_IS_VIDEOS_MODE);
isOnCourseOutline = bundle.getBoolean(Router.EXTRA_IS_ON_COURSE_OUTLINE);
View view = inflater.inflate(R.layout.fragment_course_outline, container, false);
listView = (ListView) view.findViewById(R.id.outline_list);
initializeAdapter();
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (deleteMode != null) {
deleteMode.finish();
}
listView.clearChoices();
CourseOutlineAdapter.SectionRow row = adapter.getItem(position);
CourseComponent comp = row.component;
if (comp.isContainer()) {
environment.getRouter().showCourseContainerOutline(CourseOutlineFragment.this, REQUEST_SHOW_COURSE_UNIT_DETAIL, courseData, comp.getId(), null, isVideoMode);
} else {
environment.getRouter().showCourseUnitDetail(CourseOutlineFragment.this, REQUEST_SHOW_COURSE_UNIT_DETAIL, courseData, comp.getId(), isVideoMode);
}
}
});
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
if (((IconImageView) view.findViewById(R.id.bulk_download)).getIcon() == FontAwesomeIcons.fa_check) {
((AppCompatActivity) getActivity()).startSupportActionMode(deleteModelCallback);
listView.setItemChecked(position, true);
return true;
}
return false;
}
});
return view;
}
Aggregations