taverna-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hiteshgautam01 <...@git.apache.org>
Subject [GitHub] incubator-taverna-mobile pull request #78: Feat: User details in nav header ...
Date Sun, 03 Jun 2018 18:22:33 GMT
Github user Hiteshgautam01 commented on a diff in the pull request:

    https://github.com/apache/incubator-taverna-mobile/pull/78#discussion_r192598247
  
    --- 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>");
    --- End diff --
    
    When I put <NA> between the strings tag it says that Element NA is not closed Because
the string file is XML based and it was reading the tags before and after the NA.


---

Mime
View raw message