Search in sources :

Example 1 with GridAvatarAdapter

use of cl.smartcities.isci.transportinspector.adapters.GridAvatarAdapter 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;
        }
    });
}
Also used : Intent(android.content.Intent) ImageView(android.widget.ImageView) AvatarView(agency.tango.android.avatarview.views.AvatarView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) GridAvatarAdapter(cl.smartcities.isci.transportinspector.adapters.GridAvatarAdapter) GridLayoutManager(android.support.v7.widget.GridLayoutManager) AvatarView(agency.tango.android.avatarview.views.AvatarView) Switch(android.widget.Switch) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) CompoundButton(android.widget.CompoundButton)

Aggregations

AvatarView (agency.tango.android.avatarview.views.AvatarView)1 Intent (android.content.Intent)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 CompoundButton (android.widget.CompoundButton)1 ImageView (android.widget.ImageView)1 Switch (android.widget.Switch)1 TextView (android.widget.TextView)1 GridAvatarAdapter (cl.smartcities.isci.transportinspector.adapters.GridAvatarAdapter)1