" + getString(R.string.attachments) + " ";
+ ArrayList
spinnerArray = new ArrayList();
+
+ ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(
+ getActivity(), android.R.layout.simple_spinner_item, spinnerArray);
+
+ spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
for (Attachment a : m_article.attachments) {
if (a.content_type != null && a.content_url != null) {
try {
URL url = new URL(a.content_url.trim());
-
- String atitle = (a.title != null && a.title.length() > 0) ? a.title : new File(url.getFile()).getName();
if (a.content_type.indexOf("image") != -1) {
content += "
";
}
- attachments += "" + atitle + ", ";
+ spinnerArray.add(a);
} catch (MalformedURLException e) {
//
@@ -203,8 +218,38 @@ public class ArticleFragment extends Fragment {
}
}
- content += attachments.replaceAll(", $", "");
- content += " ";
+
+ spinner.setAdapter(spinnerArrayAdapter);
+
+ Button attachmentsView = (Button) view.findViewById(R.id.attachment_view);
+
+ attachmentsView.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ Attachment attachment = (Attachment) spinner.getSelectedItem();
+
+ Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(attachment.content_url));
+ startActivity(browserIntent);
+ }
+ });
+
+ Button attachmentsCopy = (Button) view.findViewById(R.id.attachment_copy);
+
+ attachmentsCopy.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ Attachment attachment = (Attachment) spinner.getSelectedItem();
+
+ if (attachment != null) {
+ m_onlineServices.copyToClipboard(attachment.content_url);
+ }
+ }
+ });
+
+ } else {
+ view.findViewById(R.id.attachments_holder).setVisibility(View.GONE);
}
content += "