-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix nav drawer #145
base: master
Are you sure you want to change the base?
Fix nav drawer #145
Conversation
private void setupEasterEgg() { | ||
Menu navigationMenu = navigationView.getMenu(); | ||
initializeNavigationHeaderView(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not right place to initializeNavigationHeaderView()
|
||
class ProfileDetailsViewModel : ViewModel() { | ||
private var profileDetails = MutableLiveData<ProfileDetails?>() | ||
fun get(serviceProvider: TestpressServiceProvider, activity: Activity): LiveData<ProfileDetails?> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use NetworkBoundResource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fetching from the network every time.
android:layout_weight="1" | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this change
|
||
private void getProfileDetailsFromViewModel() { | ||
if (isUserAuthenticated) { | ||
profileDetailsViewModel.get(serviceProvider, this).observe(this, new Observer<ProfileDetails>() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need to pass serviceProvider. Create repository and inject it in constructor
} | ||
|
||
private void setProfileDetailsOnDrawer() { | ||
if (profileDetails == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Resource class to check if get is a success or error
} else { | ||
navigationHeader.setVisibility(View.VISIBLE); | ||
username.setText(profileDetails.getDisplayName()); | ||
getBitmapFromString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this name
ImageLoader.getInstance().loadImage(profileDetails.getPhoto(), new SimpleImageLoadingListener() { | ||
@Override | ||
public void onLoadingFailed(String imageUri, View view, FailReason failReason) { | ||
hideNavigationHeader(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not hide the navigation header if image fetch is failed. Show placeholder instead.
navigationHeader.setVisibility(View.VISIBLE); | ||
username.setText(profileDetails.getDisplayName()); | ||
getBitmapFromString(); | ||
setOnClickListener(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call this method in onCreateView
app:strokeWidth="1dp"> | ||
|
||
<ImageView | ||
android:id="@+id/img_profile" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
android:id="@+id/img_profile" | |
android:id="@+id/profile_image" |
<View | ||
android:layout_width="match_parent" | ||
android:layout_height="1dp" | ||
android:layout_marginTop="25dp" | ||
android:background="@color/grey_icon" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use navigation menu's divider
c686873
to
f9b09e8
Compare
Changes done
-Added a viewmodel to get the profileDetails