Skip to content

Commit

Permalink
Update PluginDetailActivity.java
Browse files Browse the repository at this point in the history
  • Loading branch information
neeldoshii committed Jun 11, 2024
1 parent 0975500 commit 5efa4d6
Showing 1 changed file with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,17 @@ public void onPlansFetched(OnPlansFetched event) {
if (event.isError()) {
AppLog.e(T.PLANS, PluginDetailActivity.class.getSimpleName() + ".onPlansFetched: "
+ event.error.type + " - " + event.error.message);
WPSnackbar.make(mBinding.pluginDetailContainer, getString(R.string.plugin_check_domain_credit_error), Snackbar.LENGTH_LONG)
.show();
WPSnackbar.make(mBinding.pluginDetailContainer, getString(R.string.plugin_check_domain_credit_error),
Snackbar.LENGTH_LONG).show();
} else {
// This should not happen
if (event.plans == null) {
String errorMessage = "Failed to fetch user Plans. The result is null.";
if (BuildConfig.DEBUG) {
throw new IllegalStateException(errorMessage);
}
WPSnackbar.make(mBinding.pluginDetailContainer, getString(R.string.plugin_check_domain_credit_error), Snackbar.LENGTH_LONG)
.show();
WPSnackbar.make(mBinding.pluginDetailContainer, getString(R.string.plugin_check_domain_credit_error),
Snackbar.LENGTH_LONG).show();
AppLog.e(T.PLANS, errorMessage);
return;
}
Expand Down Expand Up @@ -413,7 +413,6 @@ public void onSaveInstanceState(@NonNull Bundle outState) {
// UI Helpers

private void setupViews() {

mBinding.pluginDescriptionContainer.setOnClickListener(
v -> toggleText(mBinding.pluginDescriptionText, mBinding.pluginDescriptionChevron));

Expand All @@ -431,7 +430,8 @@ private void setupViews() {
toggleText(mBinding.pluginWhatsnewText, mBinding.pluginWhatsnewChevron);
}

mBinding.pluginFaqContainer.setOnClickListener(v -> toggleText(mBinding.pluginFaqText, mBinding.pluginFaqChevron));
mBinding.pluginFaqContainer.setOnClickListener(v -> toggleText(mBinding.pluginFaqText,
mBinding.pluginFaqChevron));

mBinding.pluginVersionLayout.setOnClickListener(v -> showPluginInfoPopup());

Expand Down Expand Up @@ -513,7 +513,8 @@ private void refreshViews() {
mBinding.textByline.setMovementMethod(WPLinkMovementMethod.getInstance());
if (!TextUtils.isEmpty(mPlugin.getAuthorAsHtml())) {
//noinspection ConstantConditions
mBinding.textByline.setText(HtmlCompat.fromHtml(mPlugin.getAuthorAsHtml(), HtmlCompat.FROM_HTML_MODE_LEGACY));
mBinding.textByline.setText(HtmlCompat.fromHtml(mPlugin.getAuthorAsHtml(),
HtmlCompat.FROM_HTML_MODE_LEGACY));
} else {
String authorName = mPlugin.getAuthorName();
String authorUrl = mPlugin.getAuthorUrl();
Expand Down Expand Up @@ -582,7 +583,8 @@ private void refreshUpdateVersionViews() {
boolean isUpdateAvailable = PluginUtils.isUpdateAvailable(mPlugin);
boolean canUpdate = isUpdateAvailable && !mIsUpdatingPlugin;
mBinding.pluginBtnUpdate.setVisibility(canUpdate ? View.VISIBLE : View.GONE);
mBinding.pluginInstalled.setVisibility(isUpdateAvailable || mIsUpdatingPlugin ? View.GONE : View.VISIBLE);
mBinding.pluginInstalled.setVisibility(
(isUpdateAvailable || mIsUpdatingPlugin) ? View.GONE : View.VISIBLE);
} else {
mBinding.pluginBtnUpdate.setVisibility(View.GONE);
mBinding.pluginInstalled.setVisibility(View.GONE);
Expand All @@ -606,20 +608,27 @@ private void refreshRatingsViews() {
int numRatingsTotal = mPlugin.getNumberOfRatings();

String numRatings = FormatUtils.formatInt(numRatingsTotal);
mBinding.pluginRatingsCardview.textNumRatings.setText(String.format(getString(R.string.plugin_num_ratings), numRatings));
mBinding.pluginRatingsCardview.textNumRatings.setText(String.format(getString(R.string.plugin_num_ratings),
numRatings));

if (mPlugin.getDownloadCount() > 0) {
String numDownloads = FormatUtils.formatInt(mPlugin.getDownloadCount());
mBinding.pluginRatingsCardview.textNumDownloads.setText(String.format(getString(R.string.plugin_num_downloads), numDownloads));
mBinding.pluginRatingsCardview.textNumDownloads.
setText(String.format(getString(R.string.plugin_num_downloads), numDownloads));
} else {
mBinding.pluginRatingsCardview.textNumDownloads.setText("");
}

setRatingsProgressBar(mBinding.pluginRatingsCardview.progress5, mPlugin.getNumberOfRatingsOfFive(), numRatingsTotal);
setRatingsProgressBar(mBinding.pluginRatingsCardview.progress4, mPlugin.getNumberOfRatingsOfFour(), numRatingsTotal);
setRatingsProgressBar(mBinding.pluginRatingsCardview.progress3, mPlugin.getNumberOfRatingsOfThree(), numRatingsTotal);
setRatingsProgressBar(mBinding.pluginRatingsCardview.progress2, mPlugin.getNumberOfRatingsOfTwo(), numRatingsTotal);
setRatingsProgressBar(mBinding.pluginRatingsCardview.progress1, mPlugin.getNumberOfRatingsOfOne(), numRatingsTotal);
setRatingsProgressBar(mBinding.pluginRatingsCardview.progress5, mPlugin.getNumberOfRatingsOfFive(),
numRatingsTotal);
setRatingsProgressBar(mBinding.pluginRatingsCardview.progress4, mPlugin.getNumberOfRatingsOfFour(),
numRatingsTotal);
setRatingsProgressBar(mBinding.pluginRatingsCardview.progress3, mPlugin.getNumberOfRatingsOfThree(),
numRatingsTotal);
setRatingsProgressBar(mBinding.pluginRatingsCardview.progress2, mPlugin.getNumberOfRatingsOfTwo(),
numRatingsTotal);
setRatingsProgressBar(mBinding.pluginRatingsCardview.progress1, mPlugin.getNumberOfRatingsOfOne(),
numRatingsTotal);

mBinding.pluginRatingsCardview.ratingBar.setRating(mPlugin.getAverageStarRating());
}
Expand Down

0 comments on commit 5efa4d6

Please sign in to comment.