aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2016-02-11 22:41:36 -0800
committerScott Jackson <daneren2005@gmail.com>2016-02-11 22:41:36 -0800
commit64ff9af045466fef4ed0443d0bb311781c9abba2 (patch)
treef7c8554ef0cec95cb903aa15261082ef84e37e46 /app/src/main/java
parent27df22fec2431300b0503cb322b3b9a030dd9ecd (diff)
downloaddsub-64ff9af045466fef4ed0443d0bb311781c9abba2.tar.gz
dsub-64ff9af045466fef4ed0443d0bb311781c9abba2.tar.bz2
dsub-64ff9af045466fef4ed0443d0bb311781c9abba2.zip
Fix crash trying to long press top row of Shares dialog
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/Util.java37
1 files changed, 20 insertions, 17 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/util/Util.java b/app/src/main/java/github/daneren2005/dsub/util/Util.java
index be9536ed..435c33c0 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/Util.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/Util.java
@@ -1245,32 +1245,35 @@ public final class Util {
}
showDetailsDialog(context, context.getResources().getString(title), headerStrings, details);
}
- public static void showDetailsDialog(Context context, String title, List<String> headers, List<String> details) {
+ public static void showDetailsDialog(Context context, String title, List<String> headers, final List<String> details) {
ListView listView = new ListView(context);
listView.setAdapter(new DetailsAdapter(context, R.layout.details_item, headers, details));
listView.setDivider(null);
listView.setScrollbarFadingEnabled(false);
- // Let the user long-click on a row to copy its value to the clipboard
- final Context contextRef = context;
- listView.setOnItemLongClickListener(new ListView.OnItemLongClickListener() {
- @Override
- public boolean onItemLongClick(AdapterView<?> parent, View view, int pos, long id) {
+ // Let the user long-click on a row to copy its value to the clipboard
+ final Context contextRef = context;
+ listView.setOnItemLongClickListener(new ListView.OnItemLongClickListener() {
+ @Override
+ public boolean onItemLongClick(AdapterView<?> parent, View view, int pos, long id) {
+ TextView nameView = (TextView) view.findViewById(R.id.detail_name);
+ TextView detailsView = (TextView) view.findViewById(R.id.detail_value);
+ if(nameView == null || detailsView == null) {
+ return false;
+ }
- TextView nameView = (TextView) view.findViewById(R.id.detail_name);
- TextView detailsView = (TextView) view.findViewById(R.id.detail_value);
- CharSequence name = nameView.getText();
- CharSequence value = detailsView.getText();
+ CharSequence name = nameView.getText();
+ CharSequence value = detailsView.getText();
- ClipboardManager clipboard = (ClipboardManager) contextRef.getSystemService(Context.CLIPBOARD_SERVICE);
- ClipData clip = ClipData.newPlainText(name, value);
- clipboard.setPrimaryClip(clip);
+ ClipboardManager clipboard = (ClipboardManager) contextRef.getSystemService(Context.CLIPBOARD_SERVICE);
+ ClipData clip = ClipData.newPlainText(name, value);
+ clipboard.setPrimaryClip(clip);
- toast(contextRef, "Copied " + name + " to clipboard");
+ toast(contextRef, "Copied " + name + " to clipboard");
- return true;
- }
- });
+ return true;
+ }
+ });
new AlertDialog.Builder(context)
// .setIcon(android.R.drawable.ic_dialog_info)