Github user Hiteshgautam01 commented on a diff in the pull request:

    
https://github.com/apache/incubator-taverna-mobile/pull/78#discussion_r192598483
  
    --- Diff: 
app/src/main/java/org/apache/taverna/mobile/ui/userprofile/UserProfileFragment.java
 ---
    @@ -0,0 +1,154 @@
    +package org.apache.taverna.mobile.ui.userprofile;
    +
    +import android.content.Intent;
    +import android.os.Bundle;
    +import android.support.v4.app.Fragment;
    +import android.view.LayoutInflater;
    +import android.view.View;
    +import android.view.ViewGroup;
    +import android.widget.TextView;
    +
    +import com.bumptech.glide.Glide;
    +import com.bumptech.glide.load.engine.DiskCacheStrategy;
    +import com.bumptech.glide.load.resource.drawable.GlideDrawable;
    +import com.bumptech.glide.request.animation.GlideAnimation;
    +import com.bumptech.glide.request.target.SimpleTarget;
    +
    +import org.apache.taverna.mobile.R;
    +import org.apache.taverna.mobile.data.DataManager;
    +import org.apache.taverna.mobile.data.local.PreferencesHelper;
    +import 
org.apache.taverna.mobile.ui.favouriteworkflow.FavouriteWorkflowsActivity;
    +import org.apache.taverna.mobile.ui.myworkflows.MyWorkflowsActivity;
    +
    +import butterknife.BindView;
    +import butterknife.ButterKnife;
    +import butterknife.OnClick;
    +import de.hdodenhof.circleimageview.CircleImageView;
    +
    +import static android.os.Build.ID;
    +
    +public class UserProfileFragment extends Fragment {
    +
    +    @BindView(R.id.user_name)
    +    TextView userName;
    +
    +    @BindView(R.id.user_avatar)
    +    CircleImageView userAvatar;
    +
    +    @BindView(R.id.user_email)
    +    TextView userEmail;
    +
    +    @BindView(R.id.user_website)
    +    TextView userWebsite;
    +
    +    @BindView(R.id.user_description)
    +    TextView userDescription;
    +
    +    @BindView(R.id.user_city)
    +    TextView userCity;
    +
    +    @BindView(R.id.user_country)
    +    TextView userCountry;
    +
    +    private DataManager dataManager;
    +
    +    public static UserProfileFragment newInstance(String id) {
    +
    +        Bundle args = new Bundle();
    +
    +        args.putString(ID, id);
    +
    +        UserProfileFragment fragment = new UserProfileFragment();
    +        fragment.setArguments(args);
    +        return fragment;
    +    }
    +
    +    @Override
    +    public View onCreateView(LayoutInflater inflater, ViewGroup parent, 
Bundle savedInstanceState) {
    +        return inflater.inflate(R.layout.fragment_user_profile, parent, 
false);
    +
    +    }
    +
    +    @Override
    +    public void onViewCreated(View view, Bundle savedInstanceState) {
    +        ButterKnife.bind(this, view);
    +
    +        setUserDetail();
    +
    +    }
    +
    +    @OnClick(R.id.my_workflow_layout)
    +    void myWorkflows(View v) {
    +        Intent intent = new Intent(getActivity(), 
MyWorkflowsActivity.class);
    +        getActivity().startActivity(intent);
    +    }
    +
    +    @OnClick(R.id.my_favorite_workflow_layout)
    +    void myFavoriteWorkflow(View v) {
    +        Intent intent = new Intent(getActivity(), 
FavouriteWorkflowsActivity.class);
    +        getActivity().startActivity(intent);
    +    }
    +
    +    private void setUserDetail() {
    +
    +        dataManager = new DataManager(new PreferencesHelper(getContext()));
    +
    +        String name = dataManager.getPreferencesHelper().getUserName();
    +        String description = 
dataManager.getPreferencesHelper().getUserDescription();
    +        String email = dataManager.getPreferencesHelper().getUserEmail();
    +        String website = 
dataManager.getPreferencesHelper().getUserWebsite();
    +        String city = dataManager.getPreferencesHelper().getUserCity();
    +        String country = 
dataManager.getPreferencesHelper().getUserCountry();
    +
    +        String avatarUrl = 
dataManager.getPreferencesHelper().getUserAvatar();
    +        Glide.with(getContext())
    +                .load(avatarUrl)
    +                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
    +                .placeholder(R.drawable.ic_account_circle_black_24dp)
    +                .error(R.drawable.ic_account_circle_black_24dp)
    +                .into(new SimpleTarget<GlideDrawable>() {
    +                    @Override
    +                    public void onResourceReady(GlideDrawable resource, 
GlideAnimation<? super
    +                            GlideDrawable> glideAnimation) {
    +                        userAvatar.setImageDrawable(resource);
    +                    }
    +                });
    +
    +        if (name != null) {
    +            userName.setText(name);
    +        } else {
    +            userName.setText("<NA>");
    +        }
    +
    +        if (description != null) {
    +            description = 
android.text.Html.fromHtml(description).toString();
    +            userDescription.setText(description);
    +        } else {
    +            userDescription.setText("");
    --- End diff --
    
    In the UI screenshot, the description is under the name of the user. If 
anyone has not included the description and we set the field to null then the 
UI does not look incomplete or blank for a field.  And if we set <NA> then it 
looks ugly under the name and the user can't find that the <NA> field is for 
description.


---

Reply via email to