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,10 +473,12 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
long storedId = mSyncedFolderProvider.storeFolderSync(syncedFolderDisplayItem);
if (storedId != -1) {
syncedFolderDisplayItem.setId(storedId);
if (syncedFolderDisplayItem.isEnabled()) {
EventBus.getDefault().post(new InitiateSyncedFolder(syncedFolderDisplayItem));
}
}
}
}
@Override
public void onSyncFolderSettingsClick(int section, SyncedFolderDisplayItem syncedFolderDisplayItem) {
@ -518,8 +520,10 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
long storedId = mSyncedFolderProvider.storeFolderSync(newCustomFolder);
if (storedId != -1) {
newCustomFolder.setId(storedId);
if (newCustomFolder.isEnabled()) {
EventBus.getDefault().post(new InitiateSyncedFolder(newCustomFolder));
}
}
mAdapter.addSyncFolderItem(newCustomFolder);
} else {
SyncedFolderDisplayItem item = syncFolderItems.get(syncedFolder.getSection()-1);
@ -533,8 +537,10 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
long storedId = mSyncedFolderProvider.storeFolderSync(item);
if (storedId != -1) {
item.setId(storedId);
if (item.isEnabled()) {
EventBus.getDefault().post(new InitiateSyncedFolder(item));
}
}
} else {
// existing synced folder setup to be updated
mSyncedFolderProvider.updateSyncFolder(item);
@ -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;