diff --git a/src/main/java/com/owncloud/android/ui/activity/FolderSyncActivity.java b/src/main/java/com/owncloud/android/ui/activity/FolderSyncActivity.java index d4a7d61334..480ecd49af 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FolderSyncActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FolderSyncActivity.java @@ -473,7 +473,9 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte long storedId = mSyncedFolderProvider.storeFolderSync(syncedFolderDisplayItem); if (storedId != -1) { syncedFolderDisplayItem.setId(storedId); - EventBus.getDefault().post(new InitiateSyncedFolder(syncedFolderDisplayItem)); + if (syncedFolderDisplayItem.isEnabled()) { + EventBus.getDefault().post(new InitiateSyncedFolder(syncedFolderDisplayItem)); + } } } } @@ -518,7 +520,9 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte long storedId = mSyncedFolderProvider.storeFolderSync(newCustomFolder); if (storedId != -1) { newCustomFolder.setId(storedId); - EventBus.getDefault().post(new InitiateSyncedFolder(newCustomFolder)); + if (newCustomFolder.isEnabled()) { + EventBus.getDefault().post(new InitiateSyncedFolder(newCustomFolder)); + } } mAdapter.addSyncFolderItem(newCustomFolder); } else { @@ -533,7 +537,9 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte long storedId = mSyncedFolderProvider.storeFolderSync(item); if (storedId != -1) { item.setId(storedId); - EventBus.getDefault().post(new InitiateSyncedFolder(item)); + if (item.isEnabled()) { + EventBus.getDefault().post(new InitiateSyncedFolder(item)); + } } } else { // existing synced folder setup to be updated @@ -557,7 +563,6 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte public void onDeleteSyncedFolderPreference(SyncedFolderParcelable syncedFolder) { mSyncedFolderProvider.deleteSyncedFolder(syncedFolder.getId()); mAdapter.removeItem(syncedFolder.getSection()); - mAdapter.notifyDataSetChanged(); } /** diff --git a/src/main/java/com/owncloud/android/utils/DisplayUtils.java b/src/main/java/com/owncloud/android/utils/DisplayUtils.java index 4b4024ae7e..350e494989 100644 --- a/src/main/java/com/owncloud/android/utils/DisplayUtils.java +++ b/src/main/java/com/owncloud/android/utils/DisplayUtils.java @@ -389,6 +389,11 @@ public class DisplayUtils { public static SpannableStringBuilder createTextWithSpan(String text, String spanText, StyleSpan style) { SpannableStringBuilder sb = new SpannableStringBuilder(text); int start = text.lastIndexOf(spanText); + + if (start < 0) { + start++; + } + int end = start + spanText.length(); sb.setSpan(style, start, end, Spannable.SPAN_INCLUSIVE_INCLUSIVE); return sb;