diff --git a/collect_app/src/main/java/org/fieldsight/naxa/contact/ContactDetailsBottomSheetFragment.java b/collect_app/src/main/java/org/fieldsight/naxa/contact/ContactDetailsBottomSheetFragment.java index c54e1a942..9cf229a65 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/contact/ContactDetailsBottomSheetFragment.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/contact/ContactDetailsBottomSheetFragment.java @@ -23,7 +23,6 @@ public class ContactDetailsBottomSheetFragment extends BottomSheetDialogFragment private View rootView; private FieldSightContactModel contactDetail; - private ImageView profilePicture; private TextView fullname, username, role, address, gender, email, skype, twitter, tango, hike, qq, googletalk, viber, whatsapp, wechat; public static ContactDetailsBottomSheetFragment newInstance() { @@ -45,7 +44,7 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, } private void ContactDetailToViews() { - profilePicture = rootView.findViewById(R.id.iv_contactdetail_image); + ImageView profilePicture = rootView.findViewById(R.id.iv_contactdetail_image); if (contactDetail.getProfilePicture() != null) { GlideApp.with(this) .load(contactDetail.getProfilePicture()) diff --git a/collect_app/src/main/java/org/fieldsight/naxa/contact/ProjectContactsFragment.java b/collect_app/src/main/java/org/fieldsight/naxa/contact/ProjectContactsFragment.java index 7fd102f50..2d85ef2f7 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/contact/ProjectContactsFragment.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/contact/ProjectContactsFragment.java @@ -32,8 +32,6 @@ public class ProjectContactsFragment extends Fragment implements ContactAdapter. private ContactAdapter contactAdapter; - private ProjectContactViewModel viewModel; - @BindView(R.id.root_layout_empty_layout) LinearLayout emptyLayout; @@ -55,7 +53,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c ContactRemoteSource.getInstance().getAll(); ViewModelFactory factory = ViewModelFactory.getInstance(); - viewModel = ViewModelProviders.of(getActivity(), factory).get(ProjectContactViewModel.class); + ProjectContactViewModel viewModel = ViewModelProviders.of(getActivity(), factory).get(ProjectContactViewModel.class); viewModel.getContacts() .observe(this, new Observer>() { @Override diff --git a/collect_app/src/main/java/org/fieldsight/naxa/contact/RoleModelTypeConverter.java b/collect_app/src/main/java/org/fieldsight/naxa/contact/RoleModelTypeConverter.java index 01dc2aa9c..cebc2b383 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/contact/RoleModelTypeConverter.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/contact/RoleModelTypeConverter.java @@ -11,6 +11,10 @@ public class RoleModelTypeConverter { + private RoleModelTypeConverter() { + + } + @TypeConverter public static String roleModelToString(RoleModel roleModel) { return GSONInstance.getInstance().toJson(roleModel); @@ -18,7 +22,8 @@ public static String roleModelToString(RoleModel roleModel) { @TypeConverter public static ArrayList stringToRoleModel(String roleModel) { - Type type = new TypeToken>() {}.getType(); - return GSONInstance.getInstance().fromJson(roleModel,type); + Type type = new TypeToken>() { + }.getType(); + return GSONInstance.getInstance().fromJson(roleModel, type); } } diff --git a/collect_app/src/main/java/org/fieldsight/naxa/data/FieldSightNotification.java b/collect_app/src/main/java/org/fieldsight/naxa/data/FieldSightNotification.java index f5ccbbac2..f2fe24e1e 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/data/FieldSightNotification.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/data/FieldSightNotification.java @@ -10,7 +10,7 @@ import androidx.room.Index; import androidx.room.PrimaryKey; - +@SuppressWarnings("PMD.ExcessiveParameterList") @Entity(indices = {@Index(value = "receivedDateTimeInMillis", unique = true)}) public class FieldSightNotification implements Parcelable { diff --git a/collect_app/src/main/java/org/fieldsight/naxa/flagform/FlaggedInstanceActivity.java b/collect_app/src/main/java/org/fieldsight/naxa/flagform/FlaggedInstanceActivity.java index 1ca62db3e..b0706c83f 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/flagform/FlaggedInstanceActivity.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/flagform/FlaggedInstanceActivity.java @@ -89,7 +89,7 @@ public class FlaggedInstanceActivity extends BaseActivity implements View.OnClic private DownloadFormsTask downloadFormsTask; private ProgressDialog dialog; - private Dialog errorDialog; + private FormsDao formsDao; private FSInstancesDao instancesDao; private TextView tvSiteIdentifier; @@ -586,7 +586,7 @@ private void showErrorDialog(String errorMessage) { runOnUiThread(new Runnable() { @Override public void run() { - errorDialog = DialogFactory.createMessageDialog(FlaggedInstanceActivity.this, getString(R.string.msg_download_task_failed), errorMessage); + Dialog errorDialog = DialogFactory.createMessageDialog(FlaggedInstanceActivity.this, getString(R.string.msg_download_task_failed), errorMessage); errorDialog.show(); } }); diff --git a/collect_app/src/main/java/org/fieldsight/naxa/forms/data/local/FieldSightFormDetails.java b/collect_app/src/main/java/org/fieldsight/naxa/forms/data/local/FieldSightFormDetails.java index 6b57ba42a..a4ded45ff 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/forms/data/local/FieldSightFormDetails.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/forms/data/local/FieldSightFormDetails.java @@ -12,6 +12,7 @@ import java.util.ArrayList; +@SuppressWarnings("PMD.ExcessiveParameterList") @Entity(tableName = "fieldsight_forms") public class FieldSightFormDetails extends FormDetails { diff --git a/collect_app/src/main/java/org/fieldsight/naxa/forms/ui/EducationalMaterialListActivity.java b/collect_app/src/main/java/org/fieldsight/naxa/forms/ui/EducationalMaterialListActivity.java index d4606df22..a65656bd9 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/forms/ui/EducationalMaterialListActivity.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/forms/ui/EducationalMaterialListActivity.java @@ -52,13 +52,11 @@ public class EducationalMaterialListActivity extends CollectAbstractActivity { List fragments = new ArrayList<>(); - private final int defaultPagerPosition = 0; + private static final int defaultPagerPosition = 0; private PagerAdapter mPagerAdapter; public ViewPager viewPager; public TabLayout tabLayout; - private String fsFormId; private String formName; - private TextView title; public static void start(Context context, String formName, Em em) { Intent intent = new Intent(context, EducationalMaterialListActivity.class); @@ -83,7 +81,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { ButterKnife.bind(this); em = getIntent().getParcelableExtra(EXTRA_OBJECT); - fsFormId = getIntent().getStringExtra(EXTRA_ID); + String fsFormId = getIntent().getStringExtra(EXTRA_ID); formName = getIntent().getStringExtra(EXTRA_MESSAGE); if (fsFormId != null && em == null) { @@ -107,7 +105,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { private void bindUI() { viewPager = findViewById(R.id.view_pager); tabLayout = findViewById(R.id.tab_layout); - title = findViewById(R.id.title); + TextView title = findViewById(R.id.title); title.setText(formName); } diff --git a/collect_app/src/main/java/org/fieldsight/naxa/login/LoginActivity.java b/collect_app/src/main/java/org/fieldsight/naxa/login/LoginActivity.java index c595a19f7..37ff42f6b 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/login/LoginActivity.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/login/LoginActivity.java @@ -49,7 +49,6 @@ public class LoginActivity extends BaseLoginActivity implements LoginView { private LoginPresenter loginPresenter; private Button mEmailSignInButton; - private ImageButton btnChangeUrl; private SignInButton btnGmailLogin; private boolean isFromGooleSignin; @@ -62,7 +61,7 @@ protected void onCreate(Bundle savedInstanceState) { mPasswordView = findViewById(R.id.password); - btnChangeUrl = findViewById(R.id.btn_change_server_url); + ImageButton btnChangeUrl = findViewById(R.id.btn_change_server_url); mEmailSignInButton = findViewById(R.id.email_sign_in_button); mEmailSignInButton.setOnClickListener(new OnClickListener() { @Override diff --git a/collect_app/src/main/java/org/fieldsight/naxa/login/model/Project.java b/collect_app/src/main/java/org/fieldsight/naxa/login/model/Project.java index 7fb8ac3bd..9cb6840d9 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/login/model/Project.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/login/model/Project.java @@ -21,6 +21,7 @@ /** * Created by Susan on 11/24/2016. */ +@SuppressWarnings("PMD.ExcessiveParameterList") @Entity(tableName = "PROJECT") public class Project implements Parcelable { diff --git a/collect_app/src/main/java/org/fieldsight/naxa/login/model/Site.java b/collect_app/src/main/java/org/fieldsight/naxa/login/model/Site.java index 11c6677a6..42152b9df 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/login/model/Site.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/login/model/Site.java @@ -20,6 +20,7 @@ import java.util.List; +@SuppressWarnings("PMD.ExcessiveParameterList") @Entity(tableName = "sites") public class Site implements Parcelable { @PrimaryKey diff --git a/collect_app/src/main/java/org/fieldsight/naxa/migrate/MigrateFieldSightActivity.java b/collect_app/src/main/java/org/fieldsight/naxa/migrate/MigrateFieldSightActivity.java index d8879abc9..7e8555bc1 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/migrate/MigrateFieldSightActivity.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/migrate/MigrateFieldSightActivity.java @@ -50,9 +50,7 @@ public class MigrateFieldSightActivity extends CollectAbstractActivity { @BindView(R.id.fieldsight_migrate_act_error_card) CardView cardViewError; - private Observable migration; - - private final int MAX_PROGRESS = 8; + private static final int MAX_PROGRESS = 8; public static void start(Context context, String usernameOrEmail) { Intent intent = new Intent(context, MigrateFieldSightActivity.class); @@ -72,7 +70,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { subtitle.setText(usernameOrEmail); - migration = viewModel.copyFromOldAccount(); + Observable migration = viewModel.copyFromOldAccount(); migration .subscribeOn(Schedulers.computation()) diff --git a/collect_app/src/main/java/org/fieldsight/naxa/network/ApiInterface.java b/collect_app/src/main/java/org/fieldsight/naxa/network/ApiInterface.java index 64a80af01..01f2b10c6 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/network/ApiInterface.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/network/ApiInterface.java @@ -53,6 +53,7 @@ import static org.fieldsight.naxa.network.APIEndpoint.GET_USER_PROFILE; import static org.fieldsight.naxa.network.APIEndpoint.REMOVE_FCM; +@SuppressWarnings("PMD.ExcessiveParameterList") public interface ApiInterface { @Deprecated diff --git a/collect_app/src/main/java/org/fieldsight/naxa/notificationslist/NotificationListActivity.java b/collect_app/src/main/java/org/fieldsight/naxa/notificationslist/NotificationListActivity.java index 24cbfba07..70bc7b3ec 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/notificationslist/NotificationListActivity.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/notificationslist/NotificationListActivity.java @@ -83,8 +83,8 @@ public class NotificationListActivity extends CollectAbstractActivity implements private NotificationListViewModel viewModel; private NotificationsAdapter adapter; - final String latest_notification = "2"; // notification type when the user scroll down - final String older_notification = "1"; // notification type when the user scrolls up + final static String LATEST_NOTIFICATION = "2"; // notification type when the user scroll down + final static String OLDER_NOTIFICATION = "1"; // notification type when the user scrolls up List mNotificationList = new ArrayList<>(); public static void start(Context context) { @@ -138,7 +138,7 @@ public void onRefresh() { return; } Timber.i("NotificationListActivity is loading"); - pullNotificationByDate(latest_notification); + pullNotificationByDate(LATEST_NOTIFICATION); isNewerLoading = true; swipeLayout.setRefreshing(false); @@ -162,7 +162,7 @@ public void onScrolled(@NotNull RecyclerView recyclerView, int dx, int dy) { int lastVisibleItem = ((LinearLayoutManager) rvNotificationList.getLayoutManager()).findLastVisibleItemPosition(); Timber.i("NotificationList, lastVisible item = %d", lastVisibleItem); if (NetworkUtils.isNetworkConnected() && !isOlderLoading && totalItemCount <= (lastVisibleItem + visibleThreshold)) { - pullNotificationByDate(older_notification); + pullNotificationByDate(OLDER_NOTIFICATION); mNotificationList.add(null); adapter.notifyDataSetChanged(); isOlderLoading = true; @@ -172,21 +172,21 @@ public void onScrolled(@NotNull RecyclerView recyclerView, int dx, int dy) { }); if (adapter.getItemCount() == 0) { - getDataFromServer(String.valueOf((System.currentTimeMillis() / 1000)), older_notification); + getDataFromServer(String.valueOf((System.currentTimeMillis() / 1000)), OLDER_NOTIFICATION); emptyLayout.setVisibility(View.VISIBLE); tvMessageNodata.setVisibility(View.VISIBLE); tvMessageNodata.setText("Loading notification please wait"); prgbar.setVisibility(View.VISIBLE); } else { emptyLayout.setVisibility(View.GONE); - pullNotificationByDate(older_notification); + pullNotificationByDate(OLDER_NOTIFICATION); } isOlderLoading = true; } private void pullNotificationByDate(String type) { FieldSightNotification lastUpdatedDate; - if (type.equals(older_notification)) { + if (type.equals(OLDER_NOTIFICATION)) { lastUpdatedDate = adapter.getLastNotification(); } else { lastUpdatedDate = adapter.getMostRecentNotification(); @@ -233,10 +233,10 @@ public FieldSightNotification apply(JSONObject json) throws Exception { @Override public void onSuccess(List list) { viewModel.saveData(list); - if (mType.equals(older_notification)) { + if (mType.equals(OLDER_NOTIFICATION)) { isOlderLoading = false; adapter.removeLoader(); - } else if (mType.equals(latest_notification)) { + } else if (mType.equals(LATEST_NOTIFICATION)) { isNewerLoading = false; swipeLayout.setRefreshing(false); } @@ -246,10 +246,10 @@ public void onSuccess(List list) { @Override public void onError(Throwable e) { Timber.e(e); - if (mType.equals(older_notification)) { + if (mType.equals(OLDER_NOTIFICATION)) { isOlderLoading = false; adapter.removeLoader(); - } else if (mType.equals(latest_notification)) { + } else if (mType.equals(LATEST_NOTIFICATION)) { isNewerLoading = false; swipeLayout.setRefreshing(false); } diff --git a/collect_app/src/main/java/org/fieldsight/naxa/scheduled/data/ScheduleForm.java b/collect_app/src/main/java/org/fieldsight/naxa/scheduled/data/ScheduleForm.java index 1d64d8f5a..02544e3fb 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/scheduled/data/ScheduleForm.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/scheduled/data/ScheduleForm.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.List; +@SuppressWarnings("PMD.ExcessiveParameterList") @Entity(tableName = "scheduled_form", primaryKeys = {"scheduleId", "formDeployedFrom"}) public class ScheduleForm { diff --git a/collect_app/src/main/java/org/fieldsight/naxa/sitedocuments/ImageViewerActivity.java b/collect_app/src/main/java/org/fieldsight/naxa/sitedocuments/ImageViewerActivity.java index 8b68796c2..1c358b748 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/sitedocuments/ImageViewerActivity.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/sitedocuments/ImageViewerActivity.java @@ -24,9 +24,6 @@ public class ImageViewerActivity extends BaseActivity { @BindView(R.id.toolbar) Toolbar toolbar; - private String url; - - public static void start(Context context, String list) { Intent intent = new Intent(context, ImageViewerActivity.class); @@ -47,7 +44,7 @@ protected void onCreate(Bundle savedInstanceState) { ButterKnife.bind(this); setupToolbar(); - url = getIntent().getExtras().getString(EXTRA_MESSAGE); + String url = getIntent().getExtras().getString(EXTRA_MESSAGE); ViewUtils.loadRemoteImage(getApplicationContext(), url) .into(ivImageViewer); diff --git a/collect_app/src/main/java/org/fieldsight/naxa/stages/data/Stage.java b/collect_app/src/main/java/org/fieldsight/naxa/stages/data/Stage.java index 27206a959..3e0999cbd 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/stages/data/Stage.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/stages/data/Stage.java @@ -14,7 +14,7 @@ import java.util.ArrayList; - +@SuppressWarnings("PMD.ExcessiveParameterList") @Entity(tableName = "stages", primaryKeys = {"id", "formDeployedFrom"}) public class Stage { diff --git a/collect_app/src/main/java/org/fieldsight/naxa/submissions/PreviousSubmissionListActivity.java b/collect_app/src/main/java/org/fieldsight/naxa/submissions/PreviousSubmissionListActivity.java index 5728cf5bb..cc6baecdf 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/submissions/PreviousSubmissionListActivity.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/submissions/PreviousSubmissionListActivity.java @@ -38,7 +38,8 @@ public class PreviousSubmissionListActivity extends CollectAbstractActivity implements PaginationAdapter.OnCardClickListener { ActionBar actionBar; - private String fsFormId, fsFormName, siteId; + private String fsFormId; + private String fsFormName; private LinearLayoutManager linearLayoutManager; private RecyclerView listFormHistory; private PaginationAdapter adapter; @@ -52,7 +53,6 @@ public class PreviousSubmissionListActivity extends CollectAbstractActivity impl private String urlFirstPage; private String urlNextPage; private Toolbar toolbar; - private String count; private CardView cardSubmissionInfo; private TextView tvTotalSubmissionMessage; private TextView tvListTitle; @@ -82,13 +82,13 @@ protected void onCreate(Bundle savedInstanceState) { fsFormId = bundle.getString(Constant.BundleKey.KEY_FS_FORM_ID); fsFormName = bundle.getString(Constant.BundleKey.KEY_FS_FORM_NAME); - siteId = bundle.getString(Constant.BundleKey.KEY_SITE_ID); + String siteId = bundle.getString(Constant.BundleKey.KEY_SITE_ID); tableName = bundle.getString(Constant.BundleKey.KEY_TABLE_NAME); offlineLatestResponse = null; urlFirstPage = FieldSightUserSession.getServerUrl(this) + "/forms/api/responses/" + fsFormId + "/" + siteId; Timber.i(urlFirstPage); - count = bundle.getString("count"); + String count = bundle.getString("count"); bindUI(); setupRecyclerView(); @@ -154,15 +154,13 @@ public void onNext(FormHistoryResponse response) { tvTotalSubmissionMessage.setText(getString(R.string.msg_no_form_submission)); if (response == null) { - - showNoDataLayout(); tvTotalSubmissionMessage.setText(getString(R.string.msg_no_form_submission)); return; } if (response.getResults().size() <= 0) { - showNoDataLayout(); + tvTotalSubmissionMessage.setText(getString(R.string.msg_no_form_submission)); return; } @@ -301,7 +299,6 @@ private void bindUI() { toolbar = findViewById(R.id.toolbar); listFormHistory = findViewById(R.id.recycler_form_history_list); progressBar = findViewById(R.id.main_progress); - tvNoData = findViewById(R.id.no_message); cardSubmissionInfo = findViewById(R.id.card_info); tvTotalSubmissionMessage = findViewById(R.id.tv_total_submission_message); tvListTitle = findViewById(R.id.tv_list_title); @@ -314,17 +311,9 @@ public void onFormClicked(FormResponse form, View view) { toFormDetail.putExtra(EXTRA_OBJECT, form); startActivity(toFormDetail); -// String transitionName = getString(R.string.transition_previous_submission); -// ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(this, view, transitionName); -// ActivityCompat.startActivity(this, toFormDetail, options.toBundle()); - } + } - @Deprecated - private void showNoDataLayout() { -// tvNoData.setVisibility(View.GONE); -// listFormHistory.setVisibility(View.GONE); - } } diff --git a/collect_app/src/main/java/org/fieldsight/naxa/survey/SurveyFormsActivity.java b/collect_app/src/main/java/org/fieldsight/naxa/survey/SurveyFormsActivity.java index d4d2be464..ed1d9b06b 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/survey/SurveyFormsActivity.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/survey/SurveyFormsActivity.java @@ -55,8 +55,6 @@ public class SurveyFormsActivity extends CollectAbstractActivity implements Titl @BindView(R.id.recycler_survey_form_list) RecyclerViewEmptySupport recyclerSurveyFormList; - private ActionBar actionBar; - private Project loadedProject; private TitleDescAdapter adapter; private SurveyFormViewModel surveyFormViewModel; @@ -105,7 +103,7 @@ public void onChanged(@Nullable List surveyForms) { private void setupToolbar() { setSupportActionBar(toolbar); - actionBar = getSupportActionBar(); + ActionBar actionBar = getSupportActionBar(); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override diff --git a/config/pmd-ruleset.xml b/config/pmd-ruleset.xml index d36c3941c..96cd8927d 100644 --- a/config/pmd-ruleset.xml +++ b/config/pmd-ruleset.xml @@ -57,31 +57,31 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + +