Search in sources :

Example 1 with YesNoDialogFragment

use of com.example.nftscmers.fragments.YesNoDialogFragment in project HackFest2022-Pretzel by chuanshaof.

the class ProfileActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_applicant_profile);
    title = findViewById(R.id.applicant_title);
    back = findViewById(R.id.applicant_back_arrow);
    editProfile = findViewById(R.id.applicant_edit_profile);
    profilePic = findViewById(R.id.applicant_profile_pic);
    name = findViewById(R.id.applicant_name);
    email = findViewById(R.id.applicant_email);
    about = findViewById(R.id.applicant_about);
    linkedIn = findViewById(R.id.applicant_linkedIn);
    logout = findViewById(R.id.button_logout);
    // Loading of previous applicant data
    new ApplicantDb(ProfileActivity.this, new ApplicantDb.OnApplicantModel() {

        @Override
        public void onResult(ApplicantModel applicantModel) {
            Log.d(TAG, "onResult: " + applicantModel);
            applicant = applicantModel;
            Utils.loadImage(profilePic, applicant.getImage());
            Utils.setValid(name, applicant.getName());
            Utils.setValid(about, applicant.getAbout());
            Utils.setValid(linkedIn, applicant.getLinkedIn());
            Utils.setValid(email, applicant.getEmail());
            SkillsFragment skillsFragment = new SkillsFragment(applicant.getSkills());
            getSupportFragmentManager().beginTransaction().replace(R.id.applicant_skills, skillsFragment).commit();
        }
    }).getApplicantModel(getIntent().getStringExtra(ProfileActivity.TAG));
    if (!getIntent().getStringExtra(ProfileActivity.TAG).equals(LoggedInUser.getInstance().getEmail())) {
        Utils.disableButton(editProfile);
        Utils.disableButton(logout);
    }
    editProfile.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(ProfileActivity.this, EditProfileActivity.class);
            startActivity(intent);
        }
    });
    logout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            new YesNoDialogFragment("Confirm Logout?", new YesNoDialogFragment.OnClickListener() {

                @Override
                public void onResult(boolean bool) {
                    if (bool == true) {
                        LoggedInUser.getInstance().setUser(null, null, null);
                        Intent intent = new Intent(ProfileActivity.this, LoginActivity.class);
                        startActivity(intent);
                    }
                }
            }).show(getSupportFragmentManager(), TAG);
        }
    });
    BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
    if (LoggedInUser.getInstance().getAccountType() == Globals.APPLICANT) {
        back.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                Intent intent = new Intent(ProfileActivity.this, ScrollJobActivity.class);
                startActivity(intent);
            }
        });
        // Set Home selected
        bottomNavigationView.setSelectedItemId(R.id.profile);
        // Perform item selected listener
        bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {

            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                switch(item.getItemId()) {
                    case R.id.history:
                        startActivity(new Intent(getApplicationContext(), ApplicationHistoryActivity.class));
                        overridePendingTransition(0, 0);
                        return true;
                    case R.id.home:
                        startActivity(new Intent(getApplicationContext(), ScrollJobActivity.class));
                        overridePendingTransition(0, 0);
                        return true;
                    case R.id.profile:
                        return true;
                }
                return false;
            }
        });
    } else {
        title.setText(getString(R.string.applicant_profile));
        back.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                Intent intent = new Intent(ProfileActivity.this, ScrollApplicationActivity.class);
                startActivity(intent);
            }
        });
        Utils.disableButton(bottomNavigationView);
    }
}
Also used : LoginActivity(com.example.nftscmers.commonactivities.LoginActivity) ApplicantModel(com.example.nftscmers.objectmodels.ApplicantModel) SkillsFragment(com.example.nftscmers.fragments.SkillsFragment) Intent(android.content.Intent) MenuItem(android.view.MenuItem) ApplicantDb(com.example.nftscmers.db.ApplicantDb) ImageView(android.widget.ImageView) View(android.view.View) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) TextView(android.widget.TextView) ListView(android.widget.ListView) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) YesNoDialogFragment(com.example.nftscmers.fragments.YesNoDialogFragment) ScrollApplicationActivity(com.example.nftscmers.employeractivities.ScrollApplicationActivity)

Example 2 with YesNoDialogFragment

use of com.example.nftscmers.fragments.YesNoDialogFragment in project HackFest2022-Pretzel by chuanshaof.

the class ProfileActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_employer_profile);
    back = findViewById(R.id.employer_back_arrow);
    editProfile = findViewById(R.id.employer_edit_profile);
    profilePic = findViewById(R.id.employer_profile_pic);
    name = findViewById(R.id.employer_name);
    email = findViewById(R.id.employer_email);
    about = findViewById(R.id.employer_about);
    linkedIn = findViewById(R.id.employer_linkedIn);
    logout = findViewById(R.id.button_logout);
    // Loading of previous employer data
    new EmployerDb(ProfileActivity.this, new EmployerDb.OnEmployerModel() {

        @Override
        public void onResult(EmployerModel employerModel) {
            Log.d(TAG, "onResult: " + employerModel);
            employer = employerModel;
            Utils.loadImage(profilePic, employer.getImage());
            Utils.setValid(name, employer.getName());
            Utils.setValid(about, employer.getAbout());
            Utils.setValid(linkedIn, employer.getWebsite());
            Utils.setValid(email, employer.getEmail());
        }
    }).getEmployerModel(getIntent().getStringExtra(TAG));
    if (!getIntent().getStringExtra(TAG).equals(LoggedInUser.getInstance().getEmail())) {
        Utils.disableButton(editProfile);
        Utils.disableButton(logout);
    }
    editProfile.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(ProfileActivity.this, EditProfileActivity.class);
            startActivity(intent);
        }
    });
    logout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            new YesNoDialogFragment("Confirm Logout?", new YesNoDialogFragment.OnClickListener() {

                @Override
                public void onResult(boolean bool) {
                    if (bool == true) {
                        LoggedInUser.getInstance().setUser(null, null, null);
                        Intent intent = new Intent(ProfileActivity.this, LoginActivity.class);
                        startActivity(intent);
                    }
                }
            }).show(getSupportFragmentManager(), TAG);
        }
    });
    BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
    if (LoggedInUser.getInstance().getAccountType() == Globals.EMPLOYER) {
        back.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                Intent intent = new Intent(com.example.nftscmers.employeractivities.ProfileActivity.this, ScrollApplicationActivity.class);
                startActivity(intent);
            }
        });
        // Set Home selected
        bottomNavigationView.setSelectedItemId(R.id.profile);
        // Perform item selected listener
        bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {

            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                switch(item.getItemId()) {
                    case R.id.history:
                        startActivity(new Intent(getApplicationContext(), JobHistoryActivity.class));
                        overridePendingTransition(0, 0);
                        return true;
                    case R.id.home:
                        startActivity(new Intent(getApplicationContext(), ScrollApplicationActivity.class));
                        overridePendingTransition(0, 0);
                        return true;
                    case R.id.create:
                        startActivity(new Intent(getApplicationContext(), EditJobActivity.class));
                        overridePendingTransition(0, 0);
                        return true;
                    case R.id.profile:
                        return true;
                }
                return false;
            }
        });
    } else {
        back.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                Intent intent = new Intent(com.example.nftscmers.employeractivities.ProfileActivity.this, ScrollJobActivity.class);
                startActivity(intent);
            }
        });
        Utils.disableButton(bottomNavigationView);
    }
}
Also used : LoginActivity(com.example.nftscmers.commonactivities.LoginActivity) EmployerModel(com.example.nftscmers.objectmodels.EmployerModel) Intent(android.content.Intent) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) View(android.view.View) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) TextView(android.widget.TextView) ListView(android.widget.ListView) EmployerDb(com.example.nftscmers.db.EmployerDb) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) YesNoDialogFragment(com.example.nftscmers.fragments.YesNoDialogFragment) ScrollJobActivity(com.example.nftscmers.applicantactivities.ScrollJobActivity)

Aggregations

Intent (android.content.Intent)2 MenuItem (android.view.MenuItem)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 LoginActivity (com.example.nftscmers.commonactivities.LoginActivity)2 YesNoDialogFragment (com.example.nftscmers.fragments.YesNoDialogFragment)2 BottomNavigationView (com.google.android.material.bottomnavigation.BottomNavigationView)2 ScrollJobActivity (com.example.nftscmers.applicantactivities.ScrollJobActivity)1 ApplicantDb (com.example.nftscmers.db.ApplicantDb)1 EmployerDb (com.example.nftscmers.db.EmployerDb)1 ScrollApplicationActivity (com.example.nftscmers.employeractivities.ScrollApplicationActivity)1 SkillsFragment (com.example.nftscmers.fragments.SkillsFragment)1 ApplicantModel (com.example.nftscmers.objectmodels.ApplicantModel)1 EmployerModel (com.example.nftscmers.objectmodels.EmployerModel)1