mirror of https://github.com/readrops/Readrops.git
Add a local account from the main activity is now possible
This commit is contained in:
parent
a12dfa6f13
commit
73b4b8e4d3
|
@ -31,6 +31,8 @@ public class AccountTypeListActivity extends AppCompatActivity {
|
||||||
private AccountTypeListAdapter adapter;
|
private AccountTypeListAdapter adapter;
|
||||||
private AccountViewModel viewModel;
|
private AccountViewModel viewModel;
|
||||||
|
|
||||||
|
private boolean fromMainActivity;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -41,7 +43,7 @@ public class AccountTypeListActivity extends AppCompatActivity {
|
||||||
binding.accountTypeRecyclerview.setLayoutManager(new LinearLayoutManager(this));
|
binding.accountTypeRecyclerview.setLayoutManager(new LinearLayoutManager(this));
|
||||||
binding.accountTypeRecyclerview.addItemDecoration(new DividerItemDecoration(this, LinearLayout.VERTICAL));
|
binding.accountTypeRecyclerview.addItemDecoration(new DividerItemDecoration(this, LinearLayout.VERTICAL));
|
||||||
|
|
||||||
boolean fromMainActivity = getIntent().getBooleanExtra("fromMainActivity", false);
|
fromMainActivity = getIntent().getBooleanExtra("fromMainActivity", false);
|
||||||
|
|
||||||
adapter = new AccountTypeListAdapter(accountType -> {
|
adapter = new AccountTypeListAdapter(accountType -> {
|
||||||
if (!(accountType.getAccountType() == Account.AccountType.LOCAL)) {
|
if (!(accountType.getAccountType() == Account.AccountType.LOCAL)) {
|
||||||
|
@ -89,10 +91,17 @@ public class AccountTypeListActivity extends AppCompatActivity {
|
||||||
public void onSuccess(Long id) {
|
public void onSuccess(Long id) {
|
||||||
account.setId(id.intValue());
|
account.setId(id.intValue());
|
||||||
|
|
||||||
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
|
if (fromMainActivity) {
|
||||||
intent.putExtra(MainActivity.ACCOUNT_KEY, account);
|
Intent intent = new Intent();
|
||||||
|
intent.putExtra(MainActivity.ACCOUNT_KEY, account);
|
||||||
|
setResult(RESULT_OK, intent);
|
||||||
|
} else {
|
||||||
|
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
|
||||||
|
intent.putExtra(MainActivity.ACCOUNT_KEY, account);
|
||||||
|
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
startActivity(intent);
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue