Inline check for 'isInstalled()'.

The adapter has its own copy of the `App`, and so can ask directly
instead of delegating to the activity.
This commit is contained in:
Peter Serwylo 2016-12-01 11:05:08 +11:00
parent 6e0ea68bab
commit 0847bb6008
2 changed files with 3 additions and 9 deletions

View File

@ -500,11 +500,6 @@ public class AppDetails2 extends AppCompatActivity implements ShareChooserDialog
return !TextUtils.isEmpty(mActiveDownloadUrlString);
}
@Override
public boolean isAppInstalled() {
return mApp.isInstalled();
}
@Override
public void enableAndroidBeam() {
NfcHelper.setAndroidBeam(this, mApp.packageName);

View File

@ -56,7 +56,6 @@ public class AppDetailsRecyclerViewAdapter
public interface AppDetailsRecyclerViewAdapterCallbacks {
boolean isAppDownloading();
boolean isAppInstalled();
void enableAndroidBeam();
void disableAndroidBeam();
void openUrl(String url);
@ -248,21 +247,21 @@ public class AppDetailsRecyclerViewAdapter
}
});
vh.buttonSecondaryView.setText(R.string.menu_uninstall);
vh.buttonSecondaryView.setVisibility(mCallbacks.isAppInstalled() ? View.VISIBLE : View.INVISIBLE);
vh.buttonSecondaryView.setVisibility(mApp.isInstalled() ? View.VISIBLE : View.INVISIBLE);
vh.buttonSecondaryView.setOnClickListener(mOnUnInstallClickListener);
vh.buttonPrimaryView.setText(R.string.menu_install);
vh.buttonPrimaryView.setVisibility(mVersions.size() > 0 ? View.VISIBLE : View.GONE);
if (mCallbacks.isAppDownloading()) {
vh.buttonPrimaryView.setText(R.string.downloading);
vh.buttonPrimaryView.setEnabled(false);
} else if (!mCallbacks.isAppInstalled() && mApp.suggestedVersionCode > 0 && mVersions.size() > 0) {
} else if (!mApp.isInstalled() && mApp.suggestedVersionCode > 0 && mVersions.size() > 0) {
// Check count > 0 due to incompatible apps resulting in an empty list.
mCallbacks.disableAndroidBeam();
// Set Install button and hide second button
vh.buttonPrimaryView.setText(R.string.menu_install);
vh.buttonPrimaryView.setOnClickListener(mOnInstallClickListener);
vh.buttonPrimaryView.setEnabled(true);
} else if (mCallbacks.isAppInstalled()) {
} else if (mApp.isInstalled()) {
mCallbacks.enableAndroidBeam();
if (mApp.canAndWantToUpdate(mContext)) {
vh.buttonPrimaryView.setText(R.string.menu_upgrade);