Browse Source

minor code review fixes

AndyScherzinger 8 years ago
parent
commit
841ad6c348

+ 4 - 16
src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactListFragment.java

@@ -81,7 +81,6 @@ import ezvcard.property.StructuredName;
 /**
  * This fragment shows all contacts from a file and allows to import them.
  */
-
 public class ContactListFragment extends FileFragment {
     public static final String TAG = ContactListFragment.class.getSimpleName();
 
@@ -90,7 +89,6 @@ public class ContactListFragment extends FileFragment {
 
     public static final String CHECKED_ITEMS_ARRAY_KEY = "CHECKED_ITEMS";
 
-
     @BindView(R.id.contactlist_recyclerview)
     public RecyclerView recyclerView;
 
@@ -139,7 +137,7 @@ public class ContactListFragment extends FileFragment {
                 vCards.addAll(Ezvcard.parse(file).all());
             }
         } catch (IOException e) {
-            e.printStackTrace();
+            Log_OC.e(TAG, "Error processing contacts file!", e);
         }
 
         restoreContacts.setOnClickListener(new View.OnClickListener() {
@@ -179,7 +177,6 @@ public class ContactListFragment extends FileFragment {
         outState.putIntArray(CHECKED_ITEMS_ARRAY_KEY, contactListAdapter.getCheckedIntArray());
     }
 
-
     @Subscribe(threadMode = ThreadMode.MAIN)
     public void onMessageEvent(VCardToggleEvent event) {
         if (event.showRestoreButton) {
@@ -189,7 +186,6 @@ public class ContactListFragment extends FileFragment {
             restoreContacts.setVisibility(View.GONE);
             restoreContacts.setBackgroundColor(getResources().getColor(R.color.standard_grey));
         }
-
     }
 
     @Override
@@ -205,7 +201,6 @@ public class ContactListFragment extends FileFragment {
         contactsPreferenceActivity.setDrawerIndicatorEnabled(false);
     }
 
-
     @Override
     public void onStart() {
         super.onStart();
@@ -235,7 +230,6 @@ public class ContactListFragment extends FileFragment {
         return retval;
     }
 
-
     static class ContactItemViewHolder extends RecyclerView.ViewHolder {
         private ImageView badge;
         private CheckedTextView name;
@@ -271,8 +265,6 @@ public class ContactListFragment extends FileFragment {
     }
 
     private void importContacts(ContactAccount account) {
-
-
         PersistableBundleCompat bundle = new PersistableBundleCompat();
         bundle.putString(ContactsImportJob.ACCOUNT_NAME, account.name);
         bundle.putString(ContactsImportJob.ACCOUNT_TYPE, account.type);
@@ -288,7 +280,6 @@ public class ContactListFragment extends FileFragment {
                 .build()
                 .schedule();
 
-
         Snackbar.make(recyclerView, R.string.contacts_preferences_import_scheduled, Snackbar.LENGTH_LONG).show();
 
         Handler handler = new Handler();
@@ -331,13 +322,14 @@ public class ContactListFragment extends FileFragment {
         } catch (Exception e) {
             Log_OC.d(TAG, e.getMessage());
         } finally {
-            cursor.close();
+            if (cursor != null) {
+                cursor.close();
+            }
         }
 
         if (accounts.size() == 1) {
             importContacts(accounts.get(0));
         } else {
-
             ArrayAdapter adapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, accounts);
             AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
             builder.setTitle(R.string.contactlist_account_chooser_title)
@@ -425,7 +417,6 @@ class ContactListAdapter extends RecyclerView.Adapter<ContactListFragment.Contac
         this.checkedVCards = checkedVCards;
     }
 
-
     public int getCheckedCount() {
         if (checkedVCards != null) {
             return checkedVCards.size();
@@ -513,8 +504,6 @@ class ContactListAdapter extends RecyclerView.Adapter<ContactListFragment.Contac
                         if (checkedVCards.size() == 1) {
                             EventBus.getDefault().post(new VCardToggleEvent(true));
                         }
-
-
                     } else {
                         if (checkedVCards.contains(position)) {
                             checkedVCards.remove(position);
@@ -533,5 +522,4 @@ class ContactListAdapter extends RecyclerView.Adapter<ContactListFragment.Contac
     public int getItemCount() {
         return vCards.size();
     }
-
 }

+ 0 - 1
src/main/res/layout/contactlist_list_item.xml

@@ -18,7 +18,6 @@
   You should have received a copy of the GNU Affero General Public
   License along with this program. If not, see <http://www.gnu.org/licenses/>.
 -->
-
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
               android:layout_width="match_parent"
               android:layout_height="@dimen/standard_list_item_size">

+ 19 - 0
src/main/res/layout/contacts_backup_fragment.xml

@@ -1,4 +1,23 @@
 <?xml version="1.0" encoding="utf-8"?>
+<!--
+  Nextcloud Android client application
+
+  Copyright (C) 2017 Tobias Kaminsky
+  Copyright (C) 2017 Nextcloud.
+
+  This program is free software; you can redistribute it and/or
+  modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+  License as published by the Free Software Foundation; either
+  version 3 of the License, or any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+  GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+
+  You should have received a copy of the GNU Affero General Public
+  License along with this program. If not, see <http://www.gnu.org/licenses/>.
+-->
 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
             android:id="@+id/contacts_linear_layout"
             android:layout_width="match_parent"