Android Open Source - json_resume Basics Resume Fragment






From Project

Back to project page json_resume.

License

The source code is released under:

/* * Copyright (c) 2015 Hunter Davis <hunter@hunterdavis.com> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided th...

If you think the Android project json_resume 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.hunterdavis.jsonresumeviewer.fragment;
//w w w  . j a v  a 2s.  c om
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.hunterdavis.jsonresumeviewer.JsonResumeActivity;
import com.hunterdavis.jsonresumeviewer.R;
import com.hunterdavis.jsonresumeviewer.types.Basics;
import com.squareup.picasso.Picasso;

/**
 * Created by hunter on 2/18/15.
 */
public class BasicsResumeFragment extends Fragment {

    /**
     * Returns a new instance of this fragment for the given section
     * number.
     */
    public static BasicsResumeFragment newInstance() {
        BasicsResumeFragment fragment = new BasicsResumeFragment();
        return fragment;
    }

    public BasicsResumeFragment() {

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_basics, container, false);

        if(JsonResumeActivity.resume != null) {
            final Basics basics =JsonResumeActivity.resume.getBasics();
            if(null != basics) {
                ImageView profileImage = (ImageView) rootView.findViewById(R.id.profileImage);
                if(!TextUtils.isEmpty(basics.getPicture())) {
                    if(profileImage != null) {
                        profileImage.setVisibility(View.VISIBLE);
                        Picasso.with(container.getContext())
                                .load(basics.getPicture())
                                .into(profileImage);
                    }
                }else {
                    profileImage.setVisibility(View.GONE);
                }

                // compose email with email click
                if(!TextUtils.isEmpty(basics.getEmail())) {
                    TextView tv = (TextView)rootView.findViewById(R.id.email);
                    if(tv != null) {
                        tv.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
                                        "mailto",basics.getEmail(), null));
                                startActivity(Intent.createChooser(emailIntent, "Send email..."));
                            }
                        });
                    }
                }

                // load view data if exist, hide if not
                loadifExistsHideIfNot(rootView,R.id.email,basics.getEmail());
                loadifExistsHideIfNot(rootView,R.id.label,basics.getLabel());
                loadifExistsHideIfNot(rootView,R.id.name,basics.getName());
                loadifExistsHideIfNot(rootView,R.id.phone,basics.getPhone());
                loadifExistsHideIfNot(rootView,R.id.summary,basics.getSummary());
                loadifExistsHideIfNot(rootView,R.id.website,basics.getWebsite());

                if(basics.getLocation() != null) {
                    loadifExistsHideIfNot(rootView, R.id.location, basics.getLocation().toString());
                }else {
                    TextView view = (TextView) rootView.findViewById(R.id.location);
                    if(view != null) {
                        view.setVisibility(View.GONE);
                    }

                }


                // go to website if exists when you click on it
                if(!TextUtils.isEmpty(basics.getWebsite())) {
                    TextView tv = (TextView)rootView.findViewById(R.id.website);
                    if(tv != null) {
                        tv.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(basics.getWebsite()));
                                startActivity(browserIntent);
                            }
                        });
                    }
                }
            }
        }

        return rootView;
    }

    public void loadifExistsHideIfNot(View container,int id, String item) {
        TextView view = (TextView) container.findViewById(id);

        if(view != null) {
            if (TextUtils.isEmpty(item)) {
                view.setVisibility(View.GONE);
                return;
            }

            view.setVisibility(View.VISIBLE);
            view.setText(item);
        }
    }
}




Java Source Code List

com.hunterdavis.jsonresumeviewer.IconDownloadTask.java
com.hunterdavis.jsonresumeviewer.JsonResumeActivity.java
com.hunterdavis.jsonresumeviewer.JsonResumeParser.java
com.hunterdavis.jsonresumeviewer.ResumePagerAdapter.java
com.hunterdavis.jsonresumeviewer.ResumeSections.java
com.hunterdavis.jsonresumeviewer.fragment.AwardsFragment.java
com.hunterdavis.jsonresumeviewer.fragment.BasicsResumeFragment.java
com.hunterdavis.jsonresumeviewer.fragment.EducationFragment.java
com.hunterdavis.jsonresumeviewer.fragment.InterestsFragment.java
com.hunterdavis.jsonresumeviewer.fragment.LanguagesFragment.java
com.hunterdavis.jsonresumeviewer.fragment.ProfileFragment.java
com.hunterdavis.jsonresumeviewer.fragment.PublicationsFragment.java
com.hunterdavis.jsonresumeviewer.fragment.ReferencesFragment.java
com.hunterdavis.jsonresumeviewer.fragment.SkillsFragment.java
com.hunterdavis.jsonresumeviewer.fragment.TextResumeFragment.java
com.hunterdavis.jsonresumeviewer.fragment.VolunteerFragment.java
com.hunterdavis.jsonresumeviewer.fragment.WorkFragment.java
com.hunterdavis.jsonresumeviewer.types.Awards.java
com.hunterdavis.jsonresumeviewer.types.Basics.java
com.hunterdavis.jsonresumeviewer.types.Education.java
com.hunterdavis.jsonresumeviewer.types.Interests.java
com.hunterdavis.jsonresumeviewer.types.Languages.java
com.hunterdavis.jsonresumeviewer.types.Location.java
com.hunterdavis.jsonresumeviewer.types.Profiles.java
com.hunterdavis.jsonresumeviewer.types.Publications.java
com.hunterdavis.jsonresumeviewer.types.References.java
com.hunterdavis.jsonresumeviewer.types.Resume.java
com.hunterdavis.jsonresumeviewer.types.Skills.java
com.hunterdavis.jsonresumeviewer.types.Volunteer.java
com.hunterdavis.jsonresumeviewer.types.Work.java