-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Replace Volley with Glide in the EditPostSettings fragment #7985
Changes from 7 commits
2304670
d24c947
bdb5d76
57d31c0
acc9d22
a2ef20b
8eaf4f5
94b4bcf
101e325
2bacc14
aa63ef5
9a6e643
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,6 @@ | |
import android.view.ContextThemeWrapper; | ||
import android.view.ViewConfiguration; | ||
|
||
import com.android.volley.toolbox.NetworkImageView; | ||
|
||
import org.wordpress.android.R; | ||
import org.wordpress.android.analytics.AnalyticsTracker; | ||
import org.wordpress.android.fluxc.model.MediaModel; | ||
|
@@ -28,7 +26,6 @@ | |
import org.wordpress.android.ui.RequestCodes; | ||
import org.wordpress.android.ui.prefs.AppPrefs; | ||
import org.wordpress.android.util.AppLog.T; | ||
import org.wordpress.android.widgets.WPNetworkImageView; | ||
import org.wordpress.passcodelock.AppLockManager; | ||
|
||
import java.io.File; | ||
|
@@ -205,8 +202,19 @@ String getErrorMessage(final Context context, final MediaModel media, final Medi | |
return context.getString(R.string.error_media_parse_error); | ||
case GENERIC_ERROR: | ||
return context.getString(R.string.error_generic_error); | ||
case EXCEEDS_SITE_SPACE_QUOTA_LIMIT: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure how I feel about adding these missing cases with just I am also not sure whether it makes sense to make it a part of this PR. I really like that you are fixing a bunch of things and I am all for it. I just think it's better to keep the PRs focused if possible (which I fail myself at times). A different approach might have been to have a really small PR that adds Glide to Just my 2 cents. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The goal here is to have all switch statements with explicitly specified cases. It all derives from
This is a topic worth discussing with everyone on the team. Thank for bringing this up @oguzkocer. I want to write a post about both these topics in a near future. Basically one of the reasons why I don't put small refactoring changes in separate PR is that Android Studio warns me about these issues when committing a change, so it's super convenient to fix it right away. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Which I agree with you, but I don't see how it has anything to do with a PR titled as
Again, I think I wasn't very clear in my comment. I have no arguments against having these missing cases. What I am worried about though is returning I just feel that a better way to fix these issues is to open a separate PR where we return specific error messages for the missing cases. Hope that clears it up! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'll create a post about this topic. I feel like minor refactoring (without changing behavior) should be part of each commit/PR, even though it's not strictly related to the PR itself.
I'm still not sure it's the way we should go. We'd change the behavior by returning specific error message and I don't think it's save to assume that all missing cases are errors -> they might be omitted on purpose, because the author wanted to return null. Explicitly returning null is definitely not ideal, but it's a change which doesn't change the behavior and moves us towards state, where it'll be safe to assume that lint takes care of warning us about all missing cases. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I definitely agree with you. My concern was the change in the meaning and that it was not very relevant to the feature.
My concern was exactly this, by adding those cases we'd just be changing the meaning of that code from
If we are not willing to spend that time, we could at least write a comment in the code explaining why they are currently returning null. |
||
return null; | ||
case NOT_AUTHENTICATED: | ||
return null; | ||
case INVALID_ID: | ||
return null; | ||
case NULL_MEDIA_ARG: | ||
return null; | ||
case MALFORMED_MEDIA_ARG: | ||
return null; | ||
case DB_QUERY_FAILURE: | ||
return null; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
|
@@ -378,32 +386,6 @@ public static boolean canDeleteMedia(MediaModel mediaModel) { | |
return state == null || (!state.equalsIgnoreCase("uploading") && !state.equalsIgnoreCase("deleted")); | ||
} | ||
|
||
/** | ||
* Loads the given network image URL into the {@link NetworkImageView}. | ||
*/ | ||
public static void loadNetworkImage(String imageUrl, WPNetworkImageView imageView) { | ||
if (imageUrl != null) { | ||
Uri uri = Uri.parse(imageUrl); | ||
String filepath = uri.getLastPathSegment(); | ||
|
||
// re-use the default background drawable as error image for now. | ||
// See: https://github.com/wordpress-mobile/WordPress-Android/pull/6295#issuecomment-315129759 | ||
imageView.setErrorImageResId(R.drawable.media_item_background); | ||
|
||
// default image while downloading | ||
imageView.setDefaultImageResId(R.drawable.media_item_background); | ||
|
||
if (MediaUtils.isValidImage(filepath)) { | ||
imageView.setTag(imageUrl); | ||
imageView.setImageUrl(imageUrl, WPNetworkImageView.ImageType.PHOTO); | ||
} else { | ||
imageView.setImageResource(R.drawable.media_item_background); | ||
} | ||
} else { | ||
imageView.setImageResource(0); | ||
} | ||
} | ||
|
||
/** | ||
* Returns a poster (thumbnail) URL given a VideoPress video URL | ||
* | ||
|
@@ -440,6 +422,7 @@ public void onScanCompleted(String path, Uri uri) { | |
/* | ||
* returns true if the current user has permission to upload new media to the passed site | ||
*/ | ||
@SuppressWarnings("SimplifiableIfStatement") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't look like a very complicated if statement, why don't we just simplify it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I felt like the comment |
||
public static boolean currentUserCanUploadMedia(@NonNull SiteModel site) { | ||
if (site.isUsingWpComRestApi()) { | ||
return site.getHasCapabilityUploadFiles(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2132,6 +2132,7 @@ | |
<string name="plugin_detail_banner_desc">plugin banner</string> | ||
<string name="plugin_detail_logo_desc">plugin logo</string> | ||
<string name="post_cardview_featured_desc">featured image</string> | ||
<string name="post_settings_featured_desc">featured image</string> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless we expect the translations to be different, we should have a string for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point:) |
||
<string name="reader_cardview_post_play_video_desc">play featured video</string> | ||
<string name="photo_picker_thumbnail_desc">Play video</string> | ||
<string name="reader_list_item_suggestion_remove_desc">delete</string> | ||
|
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.
I think we should just use a lint rule for this. I assume we can't do it right away as there are probably some
switch
statements that don't have all the branches, but we could fix them and enable the lint rule afterwards.Even if this is the approach we decide to take, let's not make it a part of an unrelated PR and instead try to add it for each
switch
statement as a single PR.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.
We actually have this rule already enabled. This switch statement is part of the lint-baseline file, so it doesn't break the build.
I'll remove the if, as you suggested;).