Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Commit

Permalink
Resolves pmd design violation (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
konishon committed Oct 15, 2019
1 parent 8fc4183 commit bdb4464
Show file tree
Hide file tree
Showing 19 changed files with 68 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<List<FieldSightContactModel>>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@

public class RoleModelTypeConverter {

private RoleModelTypeConverter() {

}

@TypeConverter
public static String roleModelToString(RoleModel roleModel) {
return GSONInstance.getInstance().toJson(roleModel);
}

@TypeConverter
public static ArrayList<RoleModel> stringToRoleModel(String roleModel) {
Type type = new TypeToken<ArrayList<RoleModel>>() {}.getType();
return GSONInstance.getInstance().fromJson(roleModel,type);
Type type = new TypeToken<ArrayList<RoleModel>>() {
}.getType();
return GSONInstance.getInstance().fromJson(roleModel, type);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import java.util.ArrayList;

@SuppressWarnings("PMD.ExcessiveParameterList")
@Entity(tableName = "fieldsight_forms")
public class FieldSightFormDetails extends FormDetails {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@ public class EducationalMaterialListActivity extends CollectAbstractActivity {
List<Fragment> 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);
Expand All @@ -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) {
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/**
* Created by Susan on 11/24/2016.
*/
@SuppressWarnings("PMD.ExcessiveParameterList")
@Entity(tableName = "PROJECT")
public class Project implements Parcelable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.List;

@SuppressWarnings("PMD.ExcessiveParameterList")
@Entity(tableName = "sites")
public class Site implements Parcelable {
@PrimaryKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ public class MigrateFieldSightActivity extends CollectAbstractActivity {
@BindView(R.id.fieldsight_migrate_act_error_card)
CardView cardViewError;

private Observable<Integer> 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);
Expand All @@ -72,7 +70,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
subtitle.setText(usernameOrEmail);


migration = viewModel.copyFromOldAccount();
Observable<Integer> migration = viewModel.copyFromOldAccount();

migration
.subscribeOn(Schedulers.computation())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<FieldSightNotification> mNotificationList = new ArrayList<>();

public static void start(Context context) {
Expand Down Expand Up @@ -138,7 +138,7 @@ public void onRefresh() {
return;
}
Timber.i("NotificationListActivity is loading");
pullNotificationByDate(latest_notification);
pullNotificationByDate(LATEST_NOTIFICATION);
isNewerLoading = true;
swipeLayout.setRefreshing(false);

Expand All @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -233,10 +233,10 @@ public FieldSightNotification apply(JSONObject json) throws Exception {
@Override
public void onSuccess(List<FieldSightNotification> 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);
}
Expand All @@ -246,10 +246,10 @@ public void onSuccess(List<FieldSightNotification> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import java.util.ArrayList;


@SuppressWarnings("PMD.ExcessiveParameterList")
@Entity(tableName = "stages",
primaryKeys = {"id", "formDeployedFrom"})
public class Stage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -105,7 +103,7 @@ public void onChanged(@Nullable List<SurveyForm> surveyForms) {
private void setupToolbar() {

setSupportActionBar(toolbar);
actionBar = getSupportActionBar();
ActionBar actionBar = getSupportActionBar();

toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
Expand Down
Loading

0 comments on commit bdb4464

Please sign in to comment.