use of fr.neamar.lolgamedata.adapter.AccountAdapter 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