@Override public View getView(int position, View convertView, final ViewGroup parent) { final Library library = this.getItem(position); final ViewHolder holder; if (convertView == null) { convertView = inflater.inflate(R.layout.listitem_opensource, null); holder = new ViewHolder(); holder.libraryName = (TextView) convertView.findViewById(R.id.libraryName); holder.libraryCreator = (TextView) convertView.findViewById(R.id.libraryCreator); holder.libraryDescription = (TextView) convertView.findViewById(R.id.libraryDescription); holder.libraryBottomDivider = convertView.findViewById(R.id.libraryBottomDivider); holder.libraryBottomContainer = convertView.findViewById(R.id.libraryBottomContainer); holder.libraryVersion = (TextView) convertView.findViewById(R.id.libraryVersion); holder.libraryLicense = (TextView) convertView.findViewById(R.id.libraryLicense); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } // Set texts holder.libraryName.setText(library.getLibraryName()); holder.libraryCreator.setText(library.getAuthor()); if (TextUtils.isEmpty(library.getLibraryDescription())) { holder.libraryDescription.setText(library.getLibraryDescription()); } else { holder.libraryDescription.setText(Html.fromHtml(library.getLibraryDescription())); } // Set License or Version Text if (TextUtils.isEmpty(library.getLibraryVersion()) && library.getLicense() != null && TextUtils.isEmpty(library.getLicense().getLicenseName()) || (!showVersion && !showLicense)) { holder.libraryBottomDivider.setVisibility(View.GONE); holder.libraryBottomContainer.setVisibility(View.GONE); } else { holder.libraryBottomDivider.setVisibility(View.VISIBLE); holder.libraryBottomContainer.setVisibility(View.VISIBLE); if (!TextUtils.isEmpty(library.getLibraryVersion()) && showVersion) { holder.libraryVersion.setText(library.getLibraryVersion()); } if (library.getLicense() != null && !TextUtils.isEmpty(library.getLicense().getLicenseName()) && showLicense) { holder.libraryLicense.setText(library.getLicense().getLicenseName()); } } // Define onClickListener if (!TextUtils.isEmpty(library.getAuthorWebsite())) { holder.libraryCreator.setOnClickListener( new OnClickListener() { @Override public void onClick(View view) { try { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(library.getAuthorWebsite())); parent.getContext().startActivity(browserIntent); } catch (Exception ex) { } } }); } if (!TextUtils.isEmpty(library.getLibraryWebsite())) { holder.libraryDescription.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { try { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(library.getLibraryWebsite())); parent.getContext().startActivity(browserIntent); } catch (Exception ex) { } } }); } if (library.getLicense() != null && !TextUtils.isEmpty((library.getLicense().getLicenseWebsite()))) { holder.libraryBottomContainer.setOnClickListener( new OnClickListener() { @Override public void onClick(View view) { try { if (showLicenseDialog && !TextUtils.isEmpty(library.getLicense().getLicenseDescription())) { AlertDialog.Builder builder = new AlertDialog.Builder(parent.getContext()); builder.setMessage(Html.fromHtml(library.getLicense().getLicenseDescription())); builder.create().show(); } else { Intent browserIntent = new Intent( Intent.ACTION_VIEW, Uri.parse(library.getLicense().getLicenseWebsite())); parent.getContext().startActivity(browserIntent); } } catch (Exception ex) { } } }); } int padding = parent.getResources().getDimensionPixelSize(R.dimen.card_padding_openSource); if (position + 1 == getCount()) { convertView.setPadding(padding, padding, padding, padding); } else { convertView.setPadding(padding, padding, padding, 0); } return convertView; }