Fix a crashing bug

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2017-07-01 22:52:05 +02:00 committed by AndyScherzinger
parent 8cabe1f3d9
commit ba5ef73d47
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
2 changed files with 14 additions and 4 deletions

View file

@ -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();
}
/**

View file

@ -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;