use of agency.tango.android.avatarview.views.AvatarView in project androidApp by InspectorIncognito.
the class NavigationDrawerActivity method handleUserSettingsChange.
protected void handleUserSettingsChange() {
if (TranSappAccountManager.isLoggedIn()) {
AvatarView imageView = navigationView.getHeaderView(0).findViewById(R.id.drawer_header_user_image);
TranSappAccountManager.getCurrentAccount().currentUser.loadImage(imageView);
}
}
use of agency.tango.android.avatarview.views.AvatarView in project androidApp by InspectorIncognito.
the class NavigationDrawerActivity method handleLoginStatus.
protected void handleLoginStatus() {
MenuItem accountItem = navigationView.getMenu().findItem(R.id.navigation_item_account);
View header = navigationView.getHeaderView(0);
if (TranSappAccountManager.isLoggedIn()) {
accountItem.setTitle(R.string.my_account);
accountItem.setIcon(ContextCompat.getDrawable(this, R.drawable.ic_account_circle_24dp));
TextView nameView = header.findViewById(R.id.drawer_header_user_name);
nameView.setText(TranSappAccountManager.getCurrentAccount().getName());
nameView.setVisibility(View.VISIBLE);
AvatarView imageView = header.findViewById(R.id.drawer_header_user_image);
TranSappAccountManager.getCurrentAccount().currentUser.loadImage(imageView);
imageView.setVisibility(View.VISIBLE);
} else {
accountItem.setTitle(R.string.log_in);
accountItem.setIcon(ContextCompat.getDrawable(this, R.drawable.ic_lock_24dp));
header.findViewById(R.id.drawer_header_user_name).setVisibility(View.GONE);
header.findViewById(R.id.drawer_header_user_image).setVisibility(View.GONE);
}
}
use of agency.tango.android.avatarview.views.AvatarView in project androidApp by InspectorIncognito.
the class AccountSettingsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_account_user_settings);
currentAccount = TranSappAccountManager.getCurrentAccount();
int level = currentAccount.currentUser.level.getLevelPosition();
serverUserAvatarId = currentAccount.currentUser.avatarId;
serverShowImageAsAvatar = !currentAccount.currentUser.showAvatar;
userAvatarId = serverUserAvatarId;
showImageAsAvatar = serverShowImageAsAvatar;
RecyclerView userGridView = findViewById(R.id.activity_account_settings_user_avatar_grid_view);
userGridView.setLayoutManager(new GridLayoutManager(this, 4));
editText = findViewById(R.id.nickname_edit_text);
editText.setText(currentAccount.currentUser.nickname);
findViewById(R.id.level_layout).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(AccountSettingsActivity.this, LevelActivity.class));
}
});
TextView levelName = findViewById(R.id.level_name);
levelName.setText(currentAccount.currentUser.level.getLevelName());
levelName.setTextColor(ContextCompat.getColor(this, currentAccount.currentUser.level.getLevelTextColor()));
ImageView levelImage = findViewById(R.id.level_image);
levelImage.setColorFilter(ContextCompat.getColor(this, currentAccount.currentUser.level.getLevelStarColor()));
AvatarView imageView = findViewById(R.id.avatar_image);
currentAccount.currentUser.loadImage(imageView);
Log.d("SettingsActivity", "creating grid");
GridAvatarAdapter userAdapter = new GridAvatarAdapter(AvatarLists.USER_AVATARS, new GridAvatarAdapter.AvatarClickListener() {
@Override
public void onNewAvatarSelected(int serverId) {
userAvatarId = serverId;
}
}, level, serverUserAvatarId);
Log.d("SettingsActivity", "setting grid");
userGridView.setAdapter(userAdapter);
Log.d("SettingsActivity", "grid ready");
Switch switchShowImage = findViewById(R.id.activity_account_settings_switch_button);
switchShowImage.setChecked(serverShowImageAsAvatar);
switchShowImage.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
showImageAsAvatar = isChecked;
}
});
}
use of agency.tango.android.avatarview.views.AvatarView in project androidApp by InspectorIncognito.
the class NicknameFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_account_nickname_fragment, container, false);
AvatarView userPicture = view.findViewById(R.id.user_image);
final SocialMediaAccount account = SocialMediaAccount.getCurrentAccount();
if (account == null) {
getActivity().finish();
return view;
}
account.loadImage(userPicture);
View submitButton = view.findViewById(R.id.submit_button);
final EditText nicknameEditText = view.findViewById(R.id.nickname_edit_text);
submitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String nickname = nicknameEditText.getText().toString();
if (nickname.length() == 0) {
Toast.makeText(getContext(), "Debes ingresar un nickname", Toast.LENGTH_SHORT).show();
} else if (nickname.length() > 30) {
Toast.makeText(getContext(), "Ingresa un nick con menos de 30 caracteres", Toast.LENGTH_SHORT).show();
} else {
final ProgressDialog dialog = new ProgressDialog(getActivity());
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setMessage("Iniciando Sesión");
dialog.setCanceledOnTouchOutside(false);
dialog.show();
TranSappAccountManager.loginWithTransapp(new AccountLogInListener() {
@Override
public void onAccountReady(TranSappAccount account) {
loginCallback.onTranSappLogin();
dialog.dismiss();
}
@Override
public void onError(ServerStatusCode error) {
dialog.dismiss();
if (error.getErrorCode() == ServerStatusCode.SERVER_ERROR || error.getErrorCode() == ServerStatusCode.INTERNAL_SERVER_ERROR || error.getErrorCode() == ServerStatusCode.PARSE_ERROR || error.getErrorCode() == ServerStatusCode.INVALID_SESSION_TOKEN) {
Toast.makeText(TranSappApplication.getAppContext(), "No se pudo iniciar sesión con TranSapp", Toast.LENGTH_SHORT).show();
}
}
}, nickname, account);
}
}
});
return view;
}
Aggregations