use of fr.neamar.lolgamedata.AccountManager in project teamward-client by Neamar.
the class SyncTokenService method onHandleIntent.
@Override
protected void onHandleIntent(Intent intent) {
AccountManager accountManager = new AccountManager(this);
ArrayList<Account> accounts = accountManager.getAccounts();
if (accounts.isEmpty()) {
Log.i(TAG, "No account yet, skipping token registration");
return;
}
Account account = accounts.get(0);
String token = FirebaseInstanceId.getInstance().getToken();
if (token == null || token.isEmpty()) {
Log.i(TAG, "Firebase token not ready yet, skipping token registration");
return;
}
// We have both a token and an account, send that to the server
sendTokenToServer(token, account);
}
use of fr.neamar.lolgamedata.AccountManager in project teamward-client by Neamar.
the class DrawerFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
accountManager = new AccountManager(getActivity());
assert getView() != null;
RecyclerView recyclerView = (RecyclerView) getView().findViewById(R.id.recyclerView);
assert recyclerView != null;
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
ArrayList<Account> accounts = accountManager.getAccounts();
final AccountAdapter adapter = new AccountAdapter(accounts);
recyclerView.setAdapter(adapter);
getView().findViewById(R.id.addLayout).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getActivity(), AddAccountActivity.class);
startActivity(i);
}
});
getView().findViewById(R.id.settingsLayout).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getActivity(), SettingsActivity.class);
startActivity(i);
}
});
mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
adapter.updateAccounts(accountManager.getAccounts());
}
};
Log.i(TAG, "Starting account change receiver");
LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mBroadcastReceiver, new IntentFilter(AccountManager.ACCOUNTS_CHANGE));
}
Aggregations