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

Commit

Permalink
Removes Useless qualified this usage in the same class. (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
konishon committed Oct 15, 2019
1 parent 96eb6cc commit 851cd71
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public final static class MetaAttrsType {
}};

public static class SERVICE {
static String SERVICE_AUTHORITY = "org.bcss.naxa.v3.network.SyncServiceV3";
public static String STOP_SYNC = SERVICE_AUTHORITY + "stop";
static final String SERVICE_AUTHORITY = "org.bcss.naxa.v3.network.SyncServiceV3";
public final static String STOP_SYNC = SERVICE_AUTHORITY + "stop";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@

public final class DialogFactory {

private DialogFactory(){

}


public static Dialog createSimpleOkErrorDialog(Context context, String title, String message) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(context, R.style.RiseUpDialog)
Expand Down Expand Up @@ -221,13 +225,11 @@ public static DatePickerDialog createDatePickerDialog(Context context, DatePicke
int curMonth = c.get(Calendar.MONTH);
int curDay = c.get(Calendar.DAY_OF_MONTH);

DatePickerDialog datePickerDialog = new DatePickerDialog(context, listener, curYear, curMonth, curDay);
return datePickerDialog;
return new DatePickerDialog(context, listener, curYear, curMonth, curDay);
}

public static AlertDialog.Builder createActionConsentDialog(Context context, String title, String message) {
View viewInflated = LayoutInflater.from(Collect.getInstance()).inflate(R.layout.dialog_site_project_filter, null, false);
AlertDialog.Builder dialog = showCustomLayoutDialog(context, viewInflated);
return dialog;
return showCustomLayoutDialog(context, viewInflated);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static int size() {
return getCompositeDisposable().size();
}

private static CompositeDisposable getCompositeDisposable() {
private synchronized static CompositeDisposable getCompositeDisposable() {
if (compositeDisposable == null || compositeDisposable.isDisposed()) {
compositeDisposable = new CompositeDisposable();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

public abstract class FieldSightDatabase extends RoomDatabase {

private static FieldSightDatabase INSTANCE;
private static FieldSightDatabase fieldSightDatabase;

public abstract SiteDao getSiteDAO();

Expand Down Expand Up @@ -114,13 +114,13 @@ public abstract class FieldSightDatabase extends RoomDatabase {
private static final String DB_PATH = Collect.METADATA_PATH + File.separator + "fieldsight_database";

public static FieldSightDatabase getDatabase(final Context context) {
if (INSTANCE != null) {
return INSTANCE;
if (fieldSightDatabase != null) {
return fieldSightDatabase;
}

synchronized (FieldSightDatabase.class) {
if (INSTANCE == null) {
INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
if (fieldSightDatabase == null) {
fieldSightDatabase = Room.databaseBuilder(context.getApplicationContext(),
FieldSightDatabase.class, DB_PATH)
.allowMainThreadQueries()//used in org.bcss.naxa.jobs.LocalNotificationJob
.addMigrations(MIGRATION_4_5, MIGRATION_5_6, MIGRATION_6_7, MIGRATION_7_8, MIGRATION_8_9,
Expand All @@ -131,7 +131,7 @@ public static FieldSightDatabase getDatabase(final Context context) {
}
}

return INSTANCE;
return fieldSightDatabase;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ public void dispatchViewChanges() {
if (adapter != null && emptyView != null) {
if (adapter.getItemCount() == 0) {
emptyView.setVisibility(View.VISIBLE);
RecyclerViewEmptySupport.this.setVisibility(View.GONE);
this.setVisibility(View.GONE);
} else {
emptyView.setVisibility(View.GONE);
RecyclerViewEmptySupport.this.setVisibility(View.VISIBLE);
this.setVisibility(View.VISIBLE);
}
}
}
Expand Down Expand Up @@ -132,17 +132,7 @@ public void setProgressView(View progressView) {
}


public void showProgressView(boolean show) {
if (show) {
emptyView.setVisibility(GONE);
RecyclerViewEmptySupport.this.setVisibility(GONE);
progressView.setVisibility(VISIBLE);
} else {
emptyView.setVisibility(VISIBLE);
RecyclerViewEmptySupport.this.setVisibility(VISIBLE);
progressView.setVisibility(GONE);
}
}


public interface OnEmptyLayoutClickListener {
void onRetryButtonClick();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void onChanged(@Nullable List<FieldSightContactModel> fieldSightContactMo
}

private void setupRecycleView() {
contactAdapter = new ContactAdapter(new ArrayList<>(0), ProjectContactsFragment.this, getActivity());
contactAdapter = new ContactAdapter(new ArrayList<>(0), this, getActivity());

LinearLayoutManager layoutManager = new GridLayoutManager(getActivity(),2);
recyclerView.setLayoutManager(layoutManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void onClick(View v) {
Bitmap bmp = BitmapFactory.decodeFile(f.getAbsolutePath());
imageView.setImageBitmap(bmp);
} else {
GlideApp.with(EduMat_ViewImageDetailsActivity.this)
GlideApp.with(this)
.load(image_url_on)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(imageView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private void setupSiteCard(FieldSightNotification loadedFieldSightNotification)

setSiteData(site.getName(), site.getIdentifier(), site.getAddress());

cardViewSite.setOnClickListener(v -> FragmentHostActivity.start(FlaggedInstanceActivity.this, site, false));
cardViewSite.setOnClickListener(v -> FragmentHostActivity.start(this, site, false));
});


Expand Down Expand Up @@ -478,7 +478,7 @@ private void downloadFormAndInstance(FieldSightNotification notificationFormDeta


private void showDialog() {
dialog = DialogFactory.createProgressDialogHorizontal(FlaggedInstanceActivity.this, "Loading Form");
dialog = DialogFactory.createProgressDialogHorizontal(this, "Loading Form");
dialog.show();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private void showErrorDialog(String msg) {
if(isFinishing()){
return;
}
Dialog dialog = DialogFactory.createActionDialog(LoginActivity.this, "Login Failed", msg)
Dialog dialog = DialogFactory.createActionDialog(this, "Login Failed", msg)
.setPositiveButton("Retry", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void googleOauthCredentials(String googleAccessToken, String username) {
String fcmToken = SharedPreferenceUtils.getFromPrefs(Collect.getInstance().getApplicationContext(), SharedPreferenceUtils.PREF_VALUE_KEY.KEY_FCM, "");
if (!TextUtils.isEmpty(fcmToken)) {
Timber.i("TOKEN generated: %s", fcmToken);
loginModel.loginViaGoogle(googleAccessToken, username, fcmToken, LoginPresenterImpl.this);
loginModel.loginViaGoogle(googleAccessToken, username, fcmToken, this);
} else {
loginView.showError("Failed to get TOKEN");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,15 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case Constant.RequestCode.RC_CAMERA:
userProfileViewModel.getUser().getValue().setProfilepic(photoToUpload.getAbsolutePath());
Glide.with(UserActivity.this)
Glide.with(this)
.load(photoToUpload)
.into(civProfilePic);
break;
case Constant.RequestCode.SELECT_FILE:
Uri uri = data.getData();
String path = ImageFileUtils.getPath(this, uri);
userProfileViewModel.getUser().getValue().setProfilepic(path);
Glide.with(UserActivity.this)
Glide.with(this)
.load(path)
.into(civProfilePic);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
viewModel = ViewModelProviders.of(this, factory).get(ProjectViewModel.class);
viewModel
.getAll(false)
.observe(ProjectListActivity.this, projects -> {
.observe(this, projects -> {
if (projectlistAdapter.getItemCount() == 0) {
projectlistAdapter.updateList(projects);
runLayoutAnimation(rvProjects);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ private void setupNavigationHeader() {
toggleNavDrawer();
new Handler()
.postDelayed(() -> {
UserActivity.start(ProjectDashboardActivity.this);
UserActivity.start(this);
}, 250);
});
} catch (IllegalArgumentException e) {
Expand Down Expand Up @@ -594,7 +594,7 @@ public void onCheckComplete() {
case R.id.action_app_settings:
if (allowClick(getClass().getName())) {

startActivity(new Intent(ProjectDashboardActivity.this, SettingsActivity.class));
startActivity(new Intent(this, SettingsActivity.class));
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ private Observable<Site> uploadSite(Site siteLocationPojo) {
siteTypeRequest = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(siteLocationPojo.getTypeId()));
}

RequestBody SiteNameRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getName());
RequestBody siteNameRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getName());
RequestBody latRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getLatitude());
RequestBody lonRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getLongitude());
RequestBody identifierRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getIdentifier());
RequestBody SitePhoneRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getPhone());
RequestBody SiteAddressRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getAddress());
RequestBody SitePublicDescRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getPublicDesc());
RequestBody sitePhoneRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getPhone());
RequestBody siteAddressRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getAddress());
RequestBody sitePublicDescRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getPublicDesc());
RequestBody projectIdRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getProject());
RequestBody isSurvey = RequestBody.create(MediaType.parse("text/plain"), "false");
RequestBody metaAttrs = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getMetaAttributes());
Expand All @@ -240,8 +240,8 @@ private Observable<Site> uploadSite(Site siteLocationPojo) {
return getRxClient()
.create(ApiInterface.class)
.uploadSite(APIEndpoint.ADD_SITE_URL, body, isSurvey
, SiteNameRequest, latRequest, lonRequest, identifierRequest, SitePhoneRequest,
SiteAddressRequest, SitePublicDescRequest, projectIdRequest, siteTypeRequest, regionId, metaAttrs);
, siteNameRequest, latRequest, lonRequest, identifierRequest, sitePhoneRequest,
siteAddressRequest, sitePublicDescRequest, projectIdRequest, siteTypeRequest, regionId, metaAttrs);
}

private Observable<Site> updateSite(Site siteLocationPojo) {
Expand All @@ -255,24 +255,24 @@ private Observable<Site> updateSite(Site siteLocationPojo) {
body = MultipartBody.Part.createFormData("logo", file.getName(), requestBody);
}

RequestBody SiteNameRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getName());
RequestBody siteNameRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getName());
RequestBody latRequest = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(siteLocationPojo.getLatitude()));
RequestBody lonRequest = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(siteLocationPojo.getLongitude()));
RequestBody identifierRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getIdentifier());
RequestBody SitePhoneRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getPhone());
RequestBody SiteAddressRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getAddress());
RequestBody SitePublicDescRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getPublicDesc());
RequestBody sitePhoneRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getPhone());
RequestBody siteAddressRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getAddress());
RequestBody sitePublicDescRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getPublicDesc());
RequestBody projectIdRequest = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getProject());
RequestBody SiteRequest = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(siteLocationPojo.getTypeId()));
RequestBody siteRequest = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(siteLocationPojo.getTypeId()));
RequestBody metaAttrs = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getMetaAttributes());
RequestBody regionId = RequestBody.create(MediaType.parse("text/plain"), siteLocationPojo.getRegionId());


return getRxClient()
.create(ApiInterface.class)
.updateSite(APIEndpoint.SITE_UPDATE_URL.concat(siteLocationPojo.getId()), body
, SiteNameRequest, latRequest, lonRequest, identifierRequest, SitePhoneRequest,
SiteAddressRequest, SitePublicDescRequest, projectIdRequest, SiteRequest, regionId, metaAttrs);
, siteNameRequest, latRequest, lonRequest, identifierRequest, sitePhoneRequest,
siteAddressRequest, sitePublicDescRequest, projectIdRequest, siteRequest, regionId, metaAttrs);

}

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

public class SiteRepository implements BaseRepository<GeneralForm> {

private static SiteRepository INSTANCE;
private static SiteRepository instance;
private final SiteLocalSource localSource;



public static SiteRepository getInstance(SiteLocalSource localSource, SiteRemoteSource remoteSource) {
if (INSTANCE == null) {
if (instance == null) {
synchronized (SiteRepository.class) {
if (INSTANCE == null) {
INSTANCE = new SiteRepository(localSource, remoteSource);
if (instance == null) {
instance = new SiteRepository(localSource, remoteSource);
}
}
}
return INSTANCE;
return instance;
}


Expand Down

0 comments on commit 851cd71

Please sign in to comment.