mirror of https://github.com/readrops/Readrops.git
Fix some sonar issues
This commit is contained in:
parent
0a73c8a6a1
commit
88f6915931
|
@ -58,7 +58,6 @@ import com.readrops.readropsdb.pojo.ItemWithFeed;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -146,7 +145,7 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
||||||
viewModel.getItemsWithFeed().observe(this, itemWithFeeds -> {
|
viewModel.getItemsWithFeed().observe(this, itemWithFeeds -> {
|
||||||
allItems = itemWithFeeds;
|
allItems = itemWithFeeds;
|
||||||
|
|
||||||
if (itemWithFeeds.size() > 0)
|
if (!itemWithFeeds.isEmpty())
|
||||||
emptyListLayout.setVisibility(View.GONE);
|
emptyListLayout.setVisibility(View.GONE);
|
||||||
else
|
else
|
||||||
emptyListLayout.setVisibility(View.VISIBLE);
|
emptyListLayout.setVisibility(View.VISIBLE);
|
||||||
|
@ -207,10 +206,10 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
||||||
drawer = drawerManager.buildDrawer(accounts);
|
drawer = drawerManager.buildDrawer(accounts);
|
||||||
drawer.setSelection(DrawerManager.ARTICLES_ITEM_ID);
|
drawer.setSelection(DrawerManager.ARTICLES_ITEM_ID);
|
||||||
updateDrawerFeeds();
|
updateDrawerFeeds();
|
||||||
} else if (accounts.size() < drawerManager.getNumberOfProfiles() && accounts.size() > 0) {
|
} else if (accounts.size() < drawerManager.getNumberOfProfiles() && !accounts.isEmpty()) {
|
||||||
drawerManager.updateHeader(accounts);
|
drawerManager.updateHeader(accounts);
|
||||||
updateDrawerFeeds();
|
updateDrawerFeeds();
|
||||||
} else if (accounts.size() == 0) {
|
} else if (accounts.isEmpty()) {
|
||||||
Intent intent = new Intent(this, AccountTypeListActivity.class);
|
Intent intent = new Intent(this, AccountTypeListActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
|
@ -422,6 +421,7 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
||||||
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
|
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
|
||||||
drawer.getDrawerLayout().setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
|
drawer.getDrawerLayout().setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
|
||||||
refreshLayout.setEnabled(false);
|
refreshLayout.setEnabled(false);
|
||||||
|
|
||||||
actionMode.getMenuInflater().inflate(R.menu.item_list_contextual_menu, menu);
|
actionMode.getMenuInflater().inflate(R.menu.item_list_contextual_menu, menu);
|
||||||
getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.primary_dark));
|
getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.primary_dark));
|
||||||
|
|
||||||
|
@ -526,38 +526,34 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||||
if (requestCode == ADD_FEED_REQUEST && resultCode == RESULT_OK) {
|
if (requestCode == ADD_FEED_REQUEST && resultCode == RESULT_OK && data != null) {
|
||||||
if (data != null) {
|
List<Feed> feeds = data.getParcelableArrayListExtra(FEEDS);
|
||||||
ArrayList<Feed> feeds = data.getParcelableArrayListExtra(FEEDS);
|
|
||||||
|
|
||||||
if (feeds != null && feeds.size() > 0 && viewModel.isAccountLocal()) {
|
if (feeds != null && !feeds.isEmpty() && viewModel.isAccountLocal()) {
|
||||||
refreshLayout.setRefreshing(true);
|
refreshLayout.setRefreshing(true);
|
||||||
feedNb = feeds.size();
|
feedNb = feeds.size();
|
||||||
sync(feeds);
|
sync(feeds);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (requestCode == MANAGE_ACCOUNT_REQUEST) {
|
} else if (requestCode == MANAGE_ACCOUNT_REQUEST) {
|
||||||
updateDrawerFeeds();
|
updateDrawerFeeds();
|
||||||
|
|
||||||
} else if (requestCode == ADD_ACCOUNT_REQUEST && resultCode == RESULT_OK) {
|
} else if (requestCode == ADD_ACCOUNT_REQUEST && resultCode == RESULT_OK && data != null) {
|
||||||
if (data != null) {
|
Account newAccount = data.getParcelableExtra(ACCOUNT);
|
||||||
Account newAccount = data.getParcelableExtra(ACCOUNT);
|
|
||||||
|
|
||||||
if (newAccount != null) {
|
if (newAccount != null) {
|
||||||
viewModel.addAccount(newAccount);
|
viewModel.addAccount(newAccount);
|
||||||
|
|
||||||
adapter.clearData();
|
adapter.clearData();
|
||||||
|
|
||||||
if (!viewModel.isAccountLocal()) {
|
if (!viewModel.isAccountLocal()) {
|
||||||
getAccountCredentials(Collections.singletonList(newAccount));
|
getAccountCredentials(Collections.singletonList(newAccount));
|
||||||
refreshLayout.setRefreshing(true);
|
refreshLayout.setRefreshing(true);
|
||||||
onRefresh();
|
onRefresh();
|
||||||
}
|
|
||||||
|
|
||||||
drawerManager.resetItems();
|
|
||||||
drawerManager.addAccount(newAccount, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drawerManager.resetItems();
|
||||||
|
drawerManager.addAccount(newAccount, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue