Android Open Source - sdk_demo_app_android Profile Activity






From Project

Back to project page sdk_demo_app_android.

License

The source code is released under:

By downloading or accessing this software, You agree to the Zendesk Terms of Service (https://www.zendesk.com/company/terms) and Application Developer and API License Agreement (https://www.zendesk.co...

If you think the Android project sdk_demo_app_android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.zendesk.rememberthedate.ui;
/*  ww  w.  j a  v  a2  s.c  o m*/
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.zendesk.rememberthedate.R;
import com.zendesk.rememberthedate.model.UserProfile;
import com.zendesk.rememberthedate.storage.UserProfileStorage;


public class ProfileActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_profile);
        if (savedInstanceState == null) {
            getFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment())
                    .commit();
        }
    }

    @Override
    protected void onResume() {
        super.onResume();

        ImageView   imageView   = (ImageView)this.findViewById(R.id.imageView);
        TextView    userName    = (TextView)this.findViewById(R.id.userName);
        TextView    email       = (TextView)this.findViewById(R.id.emailView);

        UserProfileStorage userProfileStorage = new UserProfileStorage(this);
        UserProfile userProfile = userProfileStorage.getProfile();

        if(userProfile.getAvatar() != null){
            imageView.setImageBitmap(userProfile.getAvatar());
        }

        userName.setText(userProfile.getName());
        email.setText(userProfile.getEmail());
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_profile, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_edit) {
            Intent intent = new Intent(this, CreateProfileActivity.class);

            startActivity(intent);
            finish();
            return true;

        }

        return super.onOptionsItemSelected(item);
    }

    /**
     * A placeholder fragment containing a simple view.
     */
    public static class PlaceholderFragment extends Fragment {

        public PlaceholderFragment() {
            // Intentionally empty
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            return inflater.inflate(R.layout.fragment_profile, container, false);
        }
    }
}




Java Source Code List

com.zendesk.rememberthedate.LocalNotification.java
com.zendesk.rememberthedate.model.UserProfile.java
com.zendesk.rememberthedate.rememberthedate.ApplicationTest.java
com.zendesk.rememberthedate.storage.UserProfileStorage.java
com.zendesk.rememberthedate.ui.CreateDateActivity.java
com.zendesk.rememberthedate.ui.CreateProfileActivity.java
com.zendesk.rememberthedate.ui.DateFragment.java
com.zendesk.rememberthedate.ui.HelpFragment.java
com.zendesk.rememberthedate.ui.MainActivity.java
com.zendesk.rememberthedate.ui.ProfileActivity.java
com.zendesk.rememberthedate.ui.RoundedImageView.java