Browse Source

satisfy codacy ;-)

tobiasKaminsky 8 years ago
parent
commit
84ff5832ba

+ 27 - 15
src/main/java/com/owncloud/android/ui/activity/ContactListFragment.java

@@ -90,10 +90,6 @@ public class ContactListFragment extends FileFragment {
         return frag;
     }
 
-    public ContactListFragment() {
-        super();
-    }
-
     @Override
     public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
 
@@ -170,8 +166,8 @@ public class ContactListFragment extends FileFragment {
     }
 
     static class ContactItemViewHolder extends RecyclerView.ViewHolder {
-        ImageView badge;
-        CheckedTextView name;
+        private ImageView badge;
+        private CheckedTextView name;
 
         ContactItemViewHolder(View itemView) {
             super(itemView);
@@ -182,9 +178,25 @@ public class ContactListFragment extends FileFragment {
             itemView.setTag(this);
         }
 
-        void setVCardListener(View.OnClickListener onClickListener) {
+        public void setVCardListener(View.OnClickListener onClickListener) {
             itemView.setOnClickListener(onClickListener);
         }
+
+        public ImageView getBadge() {
+            return badge;
+        }
+
+        public void setBadge(ImageView badge) {
+            this.badge = badge;
+        }
+
+        public CheckedTextView getName() {
+            return name;
+        }
+
+        public void setName(CheckedTextView name) {
+            this.name = name;
+        }
     }
 
     private void importContacts(ContactAccount account) {
@@ -294,9 +306,9 @@ public class ContactListFragment extends FileFragment {
     }
 
     private class ContactAccount {
-        String displayName;
-        String name;
-        String type;
+        private String displayName;
+        private String name;
+        private String type;
 
         ContactAccount(String displayName, String name, String type) {
             this.displayName = displayName;
@@ -353,18 +365,18 @@ class ContactListAdapter extends RecyclerView.Adapter<ContactListFragment.Contac
                 RoundedBitmapDrawable drawable = BitmapUtils.bitmapToCircularBitmapDrawable(context.getResources(),
                         thumbnail);
 
-                holder.badge.setImageDrawable(drawable);
+                holder.getBadge().setImageDrawable(drawable);
             } else {
-                holder.badge.setImageResource(R.drawable.ic_user);
+                holder.getBadge().setImageResource(R.drawable.ic_user);
             }
 
             // Checkbox
             holder.setVCardListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View v) {
-                    holder.name.setChecked(!holder.name.isChecked());
+                    holder.getName().setChecked(!holder.getName().isChecked());
 
-                    if (holder.name.isChecked()) {
+                    if (holder.getName().isChecked()) {
                         vCardClickListener.onVCardCheck(holder.getAdapterPosition());
                     } else {
                         vCardClickListener.onVCardUncheck(holder.getAdapterPosition());
@@ -376,7 +388,7 @@ class ContactListAdapter extends RecyclerView.Adapter<ContactListFragment.Contac
             StructuredName name = vcard.getStructuredName();
             String first = (name.getGiven() == null) ? "" : name.getGiven() + " ";
             String last = (name.getFamily() == null) ? "" : name.getFamily();
-            holder.name.setText(first + last);
+            holder.getName().setText(first + last);
         }
     }
 

+ 56 - 54
src/main/java/com/owncloud/android/ui/activity/ContactsPreferenceActivity.java

@@ -220,63 +220,64 @@ public class ContactsPreferenceActivity extends FileActivity implements FileFrag
         int year = cal.get(Calendar.YEAR);
         int month = cal.get(Calendar.MONTH) + 1;
         int day = cal.get(Calendar.DAY_OF_MONTH);
-        DatePickerDialog datePickerDialog = new DatePickerDialog(this, dateSetListener, year, month, day);
-        datePickerDialog.getDatePicker().setMaxDate(backupFiles.lastElement().getModificationTimestamp());
-        datePickerDialog.getDatePicker().setMinDate(backupFiles.firstElement().getModificationTimestamp());
-
-        datePickerDialog.show();
-    }
 
-    DatePickerDialog.OnDateSetListener dateSetListener = new DatePickerDialog.OnDateSetListener() {
-        @Override
-        public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
-            String backupFolderString = getResources().getString(R.string.contacts_backup_folder) + OCFile.PATH_SEPARATOR;
-            OCFile backupFolder = getStorageManager().getFileByPath(backupFolderString);
-            Vector<OCFile> backupFiles = getStorageManager().getFolderContent(backupFolder, false);
-
-            // find file with modification with date and time between 00:00 and 23:59
-            // if more than one file exists, take oldest
-            Calendar date = Calendar.getInstance();
-            date.set(year, month, dayOfMonth);
-
-            // start
-            date.set(Calendar.HOUR, 0);
-            date.set(Calendar.MINUTE, 0);
-            date.set(Calendar.SECOND, 1);
-            date.set(Calendar.MILLISECOND, 0);
-            date.set(Calendar.AM_PM, Calendar.AM);
-            Long start = date.getTimeInMillis();
-
-            // end
-            date.set(Calendar.HOUR, 23);
-            date.set(Calendar.MINUTE, 59);
-            date.set(Calendar.SECOND, 59);
-            Long end = date.getTimeInMillis();
-
-            OCFile backupToRestore = null;
-
-            for (OCFile file : backupFiles) {
-                if (start < file.getModificationTimestamp() && end > file.getModificationTimestamp()) {
-                    if (backupToRestore == null) {
-                        backupToRestore = file;
-                    } else if (backupToRestore.getModificationTimestamp() < file.getModificationTimestamp()) {
-                        backupToRestore = file;
+        DatePickerDialog.OnDateSetListener dateSetListener = new DatePickerDialog.OnDateSetListener() {
+            @Override
+            public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
+                String backupFolderString = getResources().getString(R.string.contacts_backup_folder) + OCFile.PATH_SEPARATOR;
+                OCFile backupFolder = getStorageManager().getFileByPath(backupFolderString);
+                Vector<OCFile> backupFiles = getStorageManager().getFolderContent(backupFolder, false);
+
+                // find file with modification with date and time between 00:00 and 23:59
+                // if more than one file exists, take oldest
+                Calendar date = Calendar.getInstance();
+                date.set(year, month, dayOfMonth);
+
+                // start
+                date.set(Calendar.HOUR, 0);
+                date.set(Calendar.MINUTE, 0);
+                date.set(Calendar.SECOND, 1);
+                date.set(Calendar.MILLISECOND, 0);
+                date.set(Calendar.AM_PM, Calendar.AM);
+                Long start = date.getTimeInMillis();
+
+                // end
+                date.set(Calendar.HOUR, 23);
+                date.set(Calendar.MINUTE, 59);
+                date.set(Calendar.SECOND, 59);
+                Long end = date.getTimeInMillis();
+
+                OCFile backupToRestore = null;
+
+                for (OCFile file : backupFiles) {
+                    if (start < file.getModificationTimestamp() && end > file.getModificationTimestamp()) {
+                        if (backupToRestore == null) {
+                            backupToRestore = file;
+                        } else if (backupToRestore.getModificationTimestamp() < file.getModificationTimestamp()) {
+                            backupToRestore = file;
+                        }
                     }
                 }
-            }
 
-            if (backupToRestore != null) {
-                Fragment contactListFragment = ContactListFragment.newInstance(backupToRestore, getAccount());
+                if (backupToRestore != null) {
+                    Fragment contactListFragment = ContactListFragment.newInstance(backupToRestore, getAccount());
 
-                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
-                transaction.replace(R.id.contacts_linear_layout, contactListFragment);
-                transaction.commit();
-            } else {
-                Toast.makeText(ContactsPreferenceActivity.this, R.string.contacts_preferences_no_file_found,
-                        Toast.LENGTH_SHORT).show();
+                    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+                    transaction.replace(R.id.contacts_linear_layout, contactListFragment);
+                    transaction.commit();
+                } else {
+                    Toast.makeText(ContactsPreferenceActivity.this, R.string.contacts_preferences_no_file_found,
+                            Toast.LENGTH_SHORT).show();
+                }
             }
-        }
-    };
+        };
+
+        DatePickerDialog datePickerDialog = new DatePickerDialog(this, dateSetListener, year, month, day);
+        datePickerDialog.getDatePicker().setMaxDate(backupFiles.lastElement().getModificationTimestamp());
+        datePickerDialog.getDatePicker().setMinDate(backupFiles.firstElement().getModificationTimestamp());
+
+        datePickerDialog.show();
+    }
 
     public static void startContactBackupJob(Account account) {
         Log_OC.d(TAG, "start daily contacts backup job");
@@ -321,6 +322,7 @@ public class ContactsPreferenceActivity extends FileActivity implements FileFrag
 
             default:
                 retval = super.onOptionsItemSelected(item);
+                break;
         }
         return retval;
     }
@@ -335,16 +337,16 @@ public class ContactsPreferenceActivity extends FileActivity implements FileFrag
 
     @Override
     public void showDetails(OCFile file) {
-
+        // not needed
     }
 
     @Override
     public void onBrowsedDownTo(OCFile folder) {
-
+        // not needed
     }
 
     @Override
     public void onTransferStateChanged(OCFile file, boolean downloading, boolean uploading) {
-
+        // not needed
     }
 }