From 0889d755d38a22ce8a5d0e03ec21ab62897c1188 Mon Sep 17 00:00:00 2001 From: Ruslan Davletshin Date: Fri, 5 Apr 2019 15:31:20 +0300 Subject: [PATCH] remove unused field --- .../main/java/org/stepic/droid/core/ScreenManager.java | 2 +- .../java/org/stepic/droid/core/ScreenManagerImpl.java | 4 ++-- .../stepic/droid/core/presenters/ProfilePresenterImpl.kt | 6 ++---- app/src/main/java/org/stepic/droid/model/UserViewModel.kt | 5 +---- .../java/org/stepic/droid/ui/fragments/ProfileFragment.kt | 8 +++----- .../view/profile_edit/ui/activity/ProfileEditActivity.kt | 5 +---- .../droid/core/presenters/ProfilePresenterTest.java | 5 ++--- 7 files changed, 12 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/org/stepic/droid/core/ScreenManager.java b/app/src/main/java/org/stepic/droid/core/ScreenManager.java index cd977176c0..5b84244f7c 100644 --- a/app/src/main/java/org/stepic/droid/core/ScreenManager.java +++ b/app/src/main/java/org/stepic/droid/core/ScreenManager.java @@ -147,7 +147,7 @@ public interface ScreenManager { void openDeepLink(Context context, BranchRoute route); - void showProfileEdit(Context context, Profile profile); + void showProfileEdit(Context context); void showProfileEditInfo(Activity activity, Profile profile); void showProfileEditPassword(Activity activity, long profileId); } diff --git a/app/src/main/java/org/stepic/droid/core/ScreenManagerImpl.java b/app/src/main/java/org/stepic/droid/core/ScreenManagerImpl.java index 0b3793d7a8..1e9807c227 100644 --- a/app/src/main/java/org/stepic/droid/core/ScreenManagerImpl.java +++ b/app/src/main/java/org/stepic/droid/core/ScreenManagerImpl.java @@ -705,11 +705,11 @@ public void openDeepLink(Context context, BranchRoute route) { } @Override - public void showProfileEdit(Context context, Profile profile) { + public void showProfileEdit(Context context) { if (context instanceof Activity) { ((Activity) context).overridePendingTransition(org.stepic.droid.R.anim.push_up, org.stepic.droid.R.anim.no_transition); } - context.startActivity(ProfileEditActivity.Companion.createIntent(context, profile)); + context.startActivity(ProfileEditActivity.Companion.createIntent(context)); } @Override diff --git a/app/src/main/java/org/stepic/droid/core/presenters/ProfilePresenterImpl.kt b/app/src/main/java/org/stepic/droid/core/presenters/ProfilePresenterImpl.kt index bab71b3efa..af7aa5a87f 100644 --- a/app/src/main/java/org/stepic/droid/core/presenters/ProfilePresenterImpl.kt +++ b/app/src/main/java/org/stepic/droid/core/presenters/ProfilePresenterImpl.kt @@ -132,8 +132,7 @@ constructor( information = stringOrEmpty((user.details)), isMyProfile = false, isPrivate = user.isPrivate, - id = userId, - profile = null) + id = userId) this.userViewModel = userViewModelLocal mainHandler.post { @@ -188,8 +187,7 @@ constructor( information = stringOrEmpty(profile.details), isMyProfile = isMyProfile, isPrivate = profile.isPrivate, - id = profile.id, - profile = profile) + id = profile.id) this.userViewModel = userViewModelLocal diff --git a/app/src/main/java/org/stepic/droid/model/UserViewModel.kt b/app/src/main/java/org/stepic/droid/model/UserViewModel.kt index 30402a3b7a..eead9f6e00 100644 --- a/app/src/main/java/org/stepic/droid/model/UserViewModel.kt +++ b/app/src/main/java/org/stepic/droid/model/UserViewModel.kt @@ -1,7 +1,5 @@ package org.stepic.droid.model -import org.stepik.android.model.user.Profile - data class UserViewModel( val fullName: String, val shortBio: String, @@ -9,6 +7,5 @@ data class UserViewModel( val imageLink: String?, val isMyProfile: Boolean, val isPrivate: Boolean, - val id: Long, - val profile: Profile? + val id: Long ) diff --git a/app/src/main/java/org/stepic/droid/ui/fragments/ProfileFragment.kt b/app/src/main/java/org/stepic/droid/ui/fragments/ProfileFragment.kt index 6cf1cf45ad..255c3c00f0 100644 --- a/app/src/main/java/org/stepic/droid/ui/fragments/ProfileFragment.kt +++ b/app/src/main/java/org/stepic/droid/ui/fragments/ProfileFragment.kt @@ -461,7 +461,7 @@ class ProfileFragment : FragmentBase(), inflater.inflate(R.menu.profile_menu, menu) menu?.findItem(R.id.menu_item_edit)?.isVisible = - localUserViewModel?.isMyProfile == true && localUserViewModel?.profile != null + localUserViewModel?.isMyProfile == true } } @@ -472,10 +472,8 @@ class ProfileFragment : FragmentBase(), return true } R.id.menu_item_edit -> { - localUserViewModel?.profile?.let { profile -> - analytic.reportAmplitudeEvent(AmplitudeAnalytic.ProfileEdit.SCREEN_OPENED) - screenManager.showProfileEdit(context, profile) - } + analytic.reportAmplitudeEvent(AmplitudeAnalytic.ProfileEdit.SCREEN_OPENED) + screenManager.showProfileEdit(context) return true } } diff --git a/app/src/main/java/org/stepik/android/view/profile_edit/ui/activity/ProfileEditActivity.kt b/app/src/main/java/org/stepik/android/view/profile_edit/ui/activity/ProfileEditActivity.kt index 99b04f173d..fbc04e4752 100644 --- a/app/src/main/java/org/stepik/android/view/profile_edit/ui/activity/ProfileEditActivity.kt +++ b/app/src/main/java/org/stepik/android/view/profile_edit/ui/activity/ProfileEditActivity.kt @@ -28,11 +28,8 @@ import javax.inject.Inject class ProfileEditActivity : AppCompatActivity(), ProfileEditView { companion object { - private const val EXTRA_PROFILE = "profile" - - fun createIntent(context: Context, profile: Profile): Intent = + fun createIntent(context: Context): Intent = Intent(context, ProfileEditActivity::class.java) - .putExtra(EXTRA_PROFILE, profile) } private lateinit var profileEditPresenter: ProfileEditPresenter diff --git a/app/src/test/java/org/stepic/droid/core/presenters/ProfilePresenterTest.java b/app/src/test/java/org/stepic/droid/core/presenters/ProfilePresenterTest.java index 6b6837da72..b767f9c74c 100644 --- a/app/src/test/java/org/stepic/droid/core/presenters/ProfilePresenterTest.java +++ b/app/src/test/java/org/stepic/droid/core/presenters/ProfilePresenterTest.java @@ -26,7 +26,6 @@ import java.util.concurrent.ThreadPoolExecutor; import io.reactivex.Observable; -import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; import static org.mockito.Matchers.any; @@ -102,7 +101,7 @@ private void generateInstructorApiModels() { String details = " DetailedInfo"; fakeUserFromApi = FakeUserGenerator.INSTANCE.generate(profileId, name, lastName, imageLink, shortBio, details); - fromApiUserViewModel = new UserViewModel(name + " " + lastName, shortBio, details, imageLink, isMyProfile, isPrivate, profileId, null); + fromApiUserViewModel = new UserViewModel(name + " " + lastName, shortBio, details, imageLink, isMyProfile, isPrivate, profileId); } private void generateLocalModels() { @@ -116,7 +115,7 @@ private void generateLocalModels() { String details = " details"; preferencesProfileModel = FakeProfileGenerator.INSTANCE.generate(profileId, name, lastName, imageLink, shortBio, details); - fromPreferencesUserViewModel = new UserViewModel(name + " " + lastName, shortBio, details, imageLink, isMyProfile, isPrivate, profileId, preferencesProfileModel); + fromPreferencesUserViewModel = new UserViewModel(name + " " + lastName, shortBio, details, imageLink, isMyProfile, isPrivate, profileId); } @Test