Skip to content
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 () > 0) with isempty #214

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ private void initNavigationViewHeader() {
image.setRatio(16, 9);
}

if (titleText.length() == 0) {
if (titleText.isEmpty()) {
container.setVisibility(View.GONE);
} else {
title.setText(titleText);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ protected boolean run() {
return false;
}

if (list.size() > 0 && list.get(0) instanceof Map) {
if (!list.isEmpty() && list.get(0) instanceof Map) {
Map<?, ?> map = (Map<?, ?>) list.get(0);
String thumbUrl = JsonHelper.getThumbUrl(map);

Expand Down
4 changes: 2 additions & 2 deletions library/src/main/java/candybar/lib/adapters/AboutAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public AboutAdapter(@NonNull Context context, int spanCount) {

mShowContributors = mContext.getResources().getBoolean(R.bool.show_contributors_dialog);

mShowPrivacyPolicy = mContext.getResources().getString(R.string.privacy_policy_link).length() > 0;
mShowPrivacyPolicy = !mContext.getResources().getString(R.string.privacy_policy_link).isEmpty();

mShowTerms = mContext.getResources().getString(R.string.terms_and_conditions_link).length() > 0;
mShowTerms = !mContext.getResources().getString(R.string.terms_and_conditions_link).isEmpty();

mShowExtraInfo = mShowContributors || mShowPrivacyPolicy || mShowTerms;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class ViewHolder extends RecyclerView.ViewHolder {
public void search(String string) {
String query = string.toLowerCase(Locale.getDefault()).trim();
mFAQs.clear();
if (query.length() == 0) mFAQs.addAll(mFAQsAll);
if (query.isEmpty()) mFAQs.addAll(mFAQsAll);
else {
for (int i = 0; i < mFAQsAll.size(); i++) {
FAQs faq = mFAQsAll.get(i);
Expand Down
12 changes: 6 additions & 6 deletions library/src/main/java/candybar/lib/adapters/HomeAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public HomeAdapter(@NonNull Context context, @NonNull List<Home> homes, int orie
}

String link = mContext.getResources().getString(R.string.google_play_dev);
if (link.length() > 0) {
if (!link.isEmpty()) {
mItemsCount += 1;
mShowMoreApps = true;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
HeaderViewHolder headerViewHolder = (HeaderViewHolder) holder;

String home_title_text = mContext.getResources().getString(R.string.home_title);
if (home_title_text.length() > 0) {
if (!home_title_text.isEmpty()) {
headerViewHolder.title.setText(home_title_text);
} else {
headerViewHolder.title.setVisibility(View.GONE);
Expand Down Expand Up @@ -303,7 +303,7 @@ public boolean onResourceReady(Bitmap bitmap, Object model, Target<Bitmap> targe
contentViewHolder.title.setTypeface(TypefaceHelper.getMedium(mContext));
contentViewHolder.title.setText(mHomes.get(finalPosition).getTitle());

if (mHomes.get(finalPosition).getSubtitle().length() > 0) {
if (!mHomes.get(finalPosition).getSubtitle().isEmpty()) {
contentViewHolder.subtitle.setText(mHomes.get(finalPosition).getSubtitle());
contentViewHolder.subtitle.setVisibility(View.VISIBLE);
}
Expand Down Expand Up @@ -428,15 +428,15 @@ private class HeaderViewHolder extends RecyclerView.ViewHolder implements View.O
card.setCardElevation(0);
}

if (mContext.getResources().getString(R.string.rate_and_review_link).length() == 0) {
if (mContext.getResources().getString(R.string.rate_and_review_link).isEmpty()) {
rate.setVisibility(View.GONE);
}

if (mContext.getResources().getString(R.string.share_link).length() == 0) {
if (mContext.getResources().getString(R.string.share_link).isEmpty()) {
share.setVisibility(View.GONE);
}

if ((!mContext.getResources().getBoolean(R.bool.enable_check_update)) || (CandyBarApplication.getConfiguration().getConfigHandler().configJson(mContext).length() == 0)) {
if ((!mContext.getResources().getBoolean(R.bool.enable_check_update)) || (CandyBarApplication.getConfiguration().getConfigHandler().configJson(mContext).isEmpty())) {
update.setVisibility(View.GONE);
}

Expand Down
6 changes: 3 additions & 3 deletions library/src/main/java/candybar/lib/adapters/IconsAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
mode.setTitle(mContext.getResources().getString(R.string.items_selected, mSelectedIcons.size()));
menu.findItem(R.id.menu_select_all).setIcon(mSelectedIcons.size() == mIcons.size()
? R.drawable.ic_toolbar_select_all_selected : R.drawable.ic_toolbar_select_all);
menu.findItem(R.id.menu_delete).setVisible(mSelectedIcons.size() > 0);
menu.findItem(R.id.menu_delete).setVisible(!mSelectedIcons.isEmpty());
return true;
}

Expand Down Expand Up @@ -382,7 +382,7 @@ public void search(String string) {
String query = string.toLowerCase(Locale.ENGLISH).trim();

mIcons = new ArrayList<>();
if (query.length() == 0) mIcons.addAll(mIconsAll);
if (query.isEmpty()) mIcons.addAll(mIconsAll);
else {
for (int i = 0; i < mIconsAll.size(); i++) {
Icon icon = mIconsAll.get(i);
Expand All @@ -394,7 +394,7 @@ public void search(String string) {
}
}

if (mIcons.size() == 0) {
if (mIcons.isEmpty()) {
CandyBarApplication.getConfiguration().getAnalyticsHandler().logEvent(
"click",
new HashMap<String, Object>() {{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public void setType(String type) {
List<String[]> requiredApps = getRequiredApps(type);
LinearLayout linearLayout = itemView.findViewById(R.id.container);

if (requiredApps.size() > 0) {
if (!requiredApps.isEmpty()) {
for (String[] requiredApp : requiredApps) {
View item = LayoutInflater.from(mContext).inflate(R.layout.fragment_presets_item_header_list, linearLayout, false);
((TextView) item.findViewById(R.id.name)).setText(requiredApp[0]);
Expand Down Expand Up @@ -296,7 +296,7 @@ public void onClick(View view) {
intent.setData(Uri.parse("kfile://" + mContext.getPackageName() + "/" + preset.getPath()));
}

if (getRequiredApps(type).size() > 0) {
if (!getRequiredApps(type).isEmpty()) {
new MaterialDialog.Builder(mContext)
.typeface(TypefaceHelper.getMedium(mContext), TypefaceHelper.getRegular(mContext))
.content(R.string.presets_required_apps_not_installed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,21 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
ContentViewHolder contentViewHolder = (ContentViewHolder) holder;
Setting setting = mSettings.get(position);

if (setting.getTitle().length() == 0) {
if (setting.getTitle().isEmpty()) {
contentViewHolder.title.setVisibility(View.GONE);
contentViewHolder.divider.setVisibility(View.GONE);
contentViewHolder.container.setVisibility(View.VISIBLE);

contentViewHolder.subtitle.setText(setting.getSubtitle());

if (setting.getContent().length() == 0) {
if (setting.getContent().isEmpty()) {
contentViewHolder.content.setVisibility(View.GONE);
} else {
contentViewHolder.content.setText(setting.getContent());
contentViewHolder.content.setVisibility(View.VISIBLE);
}

if (setting.getFooter().length() == 0) {
if (setting.getFooter().isEmpty()) {
contentViewHolder.footer.setVisibility(View.GONE);
} else {
contentViewHolder.footer.setText(setting.getFooter());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> tar
public void search(String string) {
String query = string.toLowerCase(Locale.getDefault()).trim();
mWallpapers.clear();
if (query.length() == 0) mWallpapers.addAll(mWallpapersAll);
if (query.isEmpty()) mWallpapers.addAll(mWallpapersAll);
else {
for (int i = 0; i < mWallpapersAll.size(); i++) {
Wallpaper wallpaper = mWallpapersAll.get(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public View getView(int position, View view, ViewGroup viewGroup) {
}
});

if (credit.getContribution().length() == 0) {
if (credit.getContribution().isEmpty()) {
holder.subtitle.setVisibility(View.GONE);
} else {
holder.subtitle.setVisibility(View.VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public View getView(int position, View view, ViewGroup viewGroup) {

holder.title.setText(otherApp.getTitle());

if (otherApp.getDescription() == null || otherApp.getDescription().length() == 0) {
if (otherApp.getDescription() == null || otherApp.getDescription().isEmpty()) {
holder.desc.setVisibility(View.GONE);
} else {
holder.desc.setText(otherApp.getDescription());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public Configuration setShowTabAllIcons(boolean showTabAllIcons) {

public Configuration setTabAllIconsTitle(@NonNull String title) {
mTabAllIconsTitle = title;
if (mTabAllIconsTitle.length() == 0) mTabAllIconsTitle = "All Icons";
if (mTabAllIconsTitle.isEmpty()) mTabAllIconsTitle = "All Icons";
return this;
}

Expand Down
8 changes: 4 additions & 4 deletions library/src/main/java/candybar/lib/databases/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public void updateWallpaper(Wallpaper wallpaper) {
values.put(KEY_COLOR, wallpaper.getColor());
}

if (values.size() > 0) {
if (!values.isEmpty()) {
mDatabase.get().mSQLiteDatabase.update(TABLE_WALLPAPERS,
values, KEY_URL + " = ?", new String[]{wallpaper.getURL()});
}
Expand Down Expand Up @@ -477,7 +477,7 @@ public Wallpaper getWallpaper(String url) {

int id = cursor.getInt(cursor.getColumnIndex(KEY_ID));
String name = cursor.getString(cursor.getColumnIndex(KEY_NAME));
if (name.length() == 0) {
if (name.isEmpty()) {
name = "Wallpaper " + id;
}

Expand Down Expand Up @@ -522,7 +522,7 @@ public List<Wallpaper> getWallpapers(@Nullable SQLiteDatabase db) {

int id = cursor.getInt(cursor.getColumnIndex(KEY_ID));
String name = cursor.getString(cursor.getColumnIndex(KEY_NAME));
if (name.length() == 0) {
if (name.isEmpty()) {
name = "Wallpaper " + id;
}

Expand Down Expand Up @@ -557,7 +557,7 @@ public Wallpaper getRandomWallpaper() {
do {
int id = cursor.getInt(cursor.getColumnIndex(KEY_ID));
String name = cursor.getString(cursor.getColumnIndex(KEY_NAME));
if (name.length() == 0) {
if (name.isEmpty()) {
name = "Wallpaper " + id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
mIcons = Database.get(requireActivity()).getBookmarkedIcons(requireActivity());
bookmarksIconFragment = new WeakReference<>(this);
isBookmarksFragment = true;
prevIsEmpty = mIcons.size() == 0;
prevIsEmpty = mIcons.isEmpty();
} else if (CandyBarMainActivity.sSections != null) {
mIcons = CandyBarMainActivity.sSections.get(index).getIcons();
}
Expand Down Expand Up @@ -138,7 +138,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
}

private void setupViewVisibility() {
if (isBookmarksFragment && mIcons.size() == 0) {
if (isBookmarksFragment && mIcons.isEmpty()) {
mNoBookmarksFoundView.setVisibility(View.VISIBLE);
mRecyclerView.setVisibility(View.GONE);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public void onClick(View view) {
}

if ((requireActivity().getResources().getBoolean(R.bool.json_check_before_request)) &&
(CandyBarApplication.getConfiguration().getConfigHandler().configJson(requireActivity()).length() != 0)) {
(!CandyBarApplication.getConfiguration().getConfigHandler().configJson(requireActivity()).isEmpty())) {
mAsyncTask = new CheckConfig().executeOnThreadPool();
} else {
mAsyncTask = new RequestLoader().executeOnThreadPool();
Expand Down Expand Up @@ -479,7 +479,7 @@ protected boolean run() {

List<ResolveInfo> resolveInfos = requireActivity().getPackageManager()
.queryIntentActivities(intent, 0);
if (resolveInfos.size() == 0) {
if (resolveInfos.isEmpty()) {
noEmailClientError = true;
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ protected boolean run() {
Thread.sleep(1);
File directory = requireActivity().getCacheDir();
requests = Database.get(requireActivity()).getPremiumRequest(null);
if (requests.size() == 0) return true;
if (requests.isEmpty()) return true;

List<String> files = new ArrayList<>();

Expand Down Expand Up @@ -335,7 +335,7 @@ protected void postRun(boolean ok) {
dialog = null;

if (ok) {
if (requests.size() == 0) {
if (requests.isEmpty()) {
Toast.makeText(getActivity(), R.string.premium_request_rebuilding_empty,
Toast.LENGTH_LONG).show();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
try {
String version = activity.getPackageManager().getPackageInfo(
activity.getPackageName(), 0).versionName;
if (version != null && version.length() > 0) {
if (version != null && !version.isEmpty()) {
changelogVersion.setText(activity.getResources().getString(
R.string.changelog_version));
changelogVersion.append(" " + version);
Expand All @@ -95,7 +95,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
}

String date = activity.getResources().getString(R.string.changelog_date);
if (date.length() > 0) changelogDate.setText(date);
if (!date.isEmpty()) changelogDate.setText(date);
else changelogDate.setVisibility(View.GONE);

String[] changelog = activity.getResources().getStringArray(R.array.changelog);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ protected boolean run() {

List<ResolveInfo> list = requireActivity().getPackageManager().queryIntentActivities(
inbox, PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() > 0) {
if (!list.isEmpty()) {
apps.add(new IntentChooser(resolveInfo, IntentChooser.TYPE_SUPPORTED));
break;
}
Expand Down Expand Up @@ -234,7 +234,7 @@ protected void postRun(boolean ok) {
mAdapter = new IntentAdapter(getActivity(), apps, mType);
mIntentList.setAdapter(mAdapter);

if (apps.size() == 0) {
if (apps.isEmpty()) {
mNoApp.setVisibility(View.VISIBLE);
setCancelable(true);
}
Expand Down
6 changes: 3 additions & 3 deletions library/src/main/java/candybar/lib/helpers/IconsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static List<Icon> getIconsList(@NonNull Context context) throws Exception
if (parser.getName().equals("category")) {
String title = parser.getAttributeValue(null, "title");
if (!sectionTitle.equals(title)) {
if (sectionTitle.length() > 0 && icons.size() > 0) {
if (!sectionTitle.isEmpty() && !icons.isEmpty()) {
count += icons.size();
sections.add(new Icon(sectionTitle, icons));
}
Expand All @@ -121,7 +121,7 @@ public static List<Icon> getIconsList(@NonNull Context context) throws Exception
CandyBarApplication.getConfiguration().getCustomIconsCount() == 0) {
CandyBarApplication.getConfiguration().setCustomIconsCount(count);
}
if (icons.size() > 0) {
if (!icons.isEmpty()) {
sections.add(new Icon(sectionTitle, icons));
}
parser.close();
Expand Down Expand Up @@ -158,7 +158,7 @@ public static void computeTitles(@NonNull Context context, List<Icon> icons) {
// Title is already computed, so continue
continue;
}
if (icon.getCustomName() != null && !icon.getCustomName().equals("")) {
if (icon.getCustomName() != null && !icon.getCustomName().isEmpty()) {
icon.setTitle(icon.getCustomName());
} else {
icon.setTitle(replaceName(context, iconReplacer, icon.getDrawableName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public static File buildBrokenDrawables(@NonNull Context context) {
}

String drawable = drawables.get(icon.getDrawableName());
if ((drawable == null || drawable.length() == 0) && !addedIcons.contains(icon.getDrawableName())) {
if ((drawable == null || drawable.isEmpty()) && !addedIcons.contains(icon.getDrawableName())) {
addedIcons.add(icon.getDrawableName());
writer.append("Drawable: ").append(icon.getDrawableName()).append(".png")
.append("\r\n\r\n");
Expand Down Expand Up @@ -216,7 +216,7 @@ public static File buildActivityList(@NonNull Context context) {
@Nullable
public static File buildCrashLog(@NonNull Context context, @NonNull String stackTrace) {
try {
if (stackTrace.length() == 0) return null;
if (stackTrace.isEmpty()) return null;

File crashLog = new File(context.getCacheDir(), CRASHLOG);
String deviceInfo = DeviceHelper.getDeviceInfoForCrashReport(context);
Expand Down
Loading
Loading