mirror of https://github.com/readrops/Readrops.git
Disable account switching when updating feeds
This commit is contained in:
parent
5d6ea2ee09
commit
e1bf8b936e
|
@ -90,6 +90,7 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
|||
private int feedNb;
|
||||
private boolean scrollToTop;
|
||||
private boolean allItemsSelected;
|
||||
private boolean updating;
|
||||
|
||||
private ActionMode actionMode;
|
||||
|
||||
|
@ -151,8 +152,10 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
|||
case DrawerManager.ACCOUNT_SETTINGS_ID:
|
||||
break;
|
||||
default:
|
||||
viewModel.setCurrentAccount(id);
|
||||
updateDrawerFeeds();
|
||||
if (!updating) {
|
||||
viewModel.setCurrentAccount(id);
|
||||
updateDrawerFeeds();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -441,6 +444,8 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
|||
@Override
|
||||
public void onRefresh() {
|
||||
Log.d(TAG, "syncing started");
|
||||
drawerManager.disableAccountSelection();
|
||||
updating = true;
|
||||
|
||||
viewModel.getFeedCount()
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -571,7 +576,9 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
|||
scrollToTop = true;
|
||||
adapter.submitList(allItems);
|
||||
|
||||
drawerManager.enableAccountSelection();
|
||||
updateDrawerFeeds(); // update drawer after syncing feeds
|
||||
updating = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import com.mikepenz.materialdrawer.model.ProfileDrawerItem;
|
|||
import com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem;
|
||||
import com.mikepenz.materialdrawer.model.SecondaryDrawerItem;
|
||||
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
|
||||
import com.mikepenz.materialdrawer.model.interfaces.IProfile;
|
||||
import com.readrops.app.R;
|
||||
import com.readrops.app.database.entities.Account;
|
||||
import com.readrops.app.database.entities.Feed;
|
||||
|
@ -182,7 +183,7 @@ public class DrawerManager {
|
|||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
secondaryDrawerItem.withIcon(resource);
|
||||
|
||||
|
||||
drawer.updateItem(secondaryDrawerItem);
|
||||
}
|
||||
|
||||
|
@ -224,4 +225,26 @@ public class DrawerManager {
|
|||
drawer.removeAllItems();
|
||||
addDefaultPlaces();
|
||||
}
|
||||
|
||||
public void disableAccountSelection() {
|
||||
List<IProfile> profiles = header.getProfiles();
|
||||
|
||||
for (IProfile profile : profiles) {
|
||||
if (profile.getIdentifier() != header.getActiveProfile().getIdentifier() && !(profile instanceof ProfileSettingDrawerItem)) {
|
||||
profile.withSelectable(false);
|
||||
header.updateProfile(profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void enableAccountSelection() {
|
||||
List<IProfile> profiles = header.getProfiles();
|
||||
|
||||
for (IProfile profile : profiles) {
|
||||
if (profile.getIdentifier() != header.getActiveProfile().getIdentifier() && !(profile instanceof ProfileSettingDrawerItem)) {
|
||||
profile.withSelectable(true);
|
||||
header.updateProfile(profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue