Commit b5c1aa9d authored by Sajal Narang's avatar Sajal Narang Committed by GitHub

Merge pull request #117 from yashkhem1/master

Added Necessary Card Views for Profile Fragment
parents 6b711929 f06b6851
package in.ac.iitb.gymkhana.iitbapp.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.util.List;
import in.ac.iitb.gymkhana.iitbapp.ItemClickListener;
import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.data.Body;
import in.ac.iitb.gymkhana.iitbapp.data.Role;
public class RoleAdapter extends RecyclerView.Adapter<RoleAdapter.ViewHolder>{
private List<Role> roleList;
private ItemClickListener itemClickListener;
private Context context;
public RoleAdapter(List<Role> roleList, ItemClickListener itemClickListener){
this.roleList = roleList;
this.itemClickListener = itemClickListener;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
context = parent.getContext();
View v = LayoutInflater.from(context)
.inflate(R.layout.role_card,parent,false);
final ViewHolder postViewHolder = new ViewHolder(v);
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
itemClickListener.onItemClick(view,postViewHolder.getAdapterPosition());
}
});
return postViewHolder;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Role role = roleList.get(position);
Body roleBody = role.getRoleBodyDetails();
holder.bodyName.setText(roleBody.getBodyName());
holder.role.setText(role.getRoleName());
Picasso.with(context).load(roleBody.getBodyImageURL()).into(holder.image);
}
@Override
public int getItemCount() {
return roleList.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
public TextView bodyName;
public TextView role;
public ImageView image;
public ViewHolder(View itemView) {
super(itemView);
bodyName = (TextView) itemView.findViewById(R.id.role_card_body);
role = (TextView) itemView.findViewById(R.id.role_card_role);
image = (ImageView) itemView.findViewById(R.id.role_card_avatar);
}
}
}
...@@ -3,6 +3,9 @@ package in.ac.iitb.gymkhana.iitbapp.fragment; ...@@ -3,6 +3,9 @@ package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -11,10 +14,16 @@ import android.widget.TextView; ...@@ -11,10 +14,16 @@ import android.widget.TextView;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import java.util.List;
import in.ac.iitb.gymkhana.iitbapp.Constants; import in.ac.iitb.gymkhana.iitbapp.Constants;
import in.ac.iitb.gymkhana.iitbapp.ItemClickListener;
import in.ac.iitb.gymkhana.iitbapp.R; import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.adapter.RoleAdapter;
import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface; import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface;
import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator; import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator;
import in.ac.iitb.gymkhana.iitbapp.data.Body;
import in.ac.iitb.gymkhana.iitbapp.data.Role;
import in.ac.iitb.gymkhana.iitbapp.data.User; import in.ac.iitb.gymkhana.iitbapp.data.User;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
...@@ -68,6 +77,24 @@ public class ProfileFragment extends BaseFragment { ...@@ -68,6 +77,24 @@ public class ProfileFragment extends BaseFragment {
TextView userEmailIDTextView = getActivity().findViewById(R.id.user_email_profile); TextView userEmailIDTextView = getActivity().findViewById(R.id.user_email_profile);
TextView userContactNumberTextView = getActivity().findViewById(R.id.user_contact_no_profile); TextView userContactNumberTextView = getActivity().findViewById(R.id.user_contact_no_profile);
final List<Role> roleList = user.getUserRoles();
RecyclerView userRoleRecyclerView = getActivity().findViewById(R.id.role_recycler_view);
RoleAdapter roleAdapter = new RoleAdapter(roleList, new ItemClickListener() {
@Override
public void onItemClick(View v, int position) {
Role role = roleList.get(position);
Body roleBody = role.getRoleBodyDetails();
BodyFragment bodyFragment = BodyFragment.newInstance(roleBody);
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
ft.replace(R.id.framelayout_for_fragment, bodyFragment, bodyFragment.getTag());
ft.addToBackStack(bodyFragment.getTag());
ft.commit();
}
});
userRoleRecyclerView.setAdapter(roleAdapter);
userRoleRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
Picasso.with(getContext()).load(user.getUserProfilePictureUrl()).into(userProfilePictureImageView); Picasso.with(getContext()).load(user.getUserProfilePictureUrl()).into(userProfilePictureImageView);
userNameTextView.setText(user.getUserName()); userNameTextView.setText(user.getUserName());
userRollNumberTextView.setText(user.getUserRollNumber()); userRollNumberTextView.setText(user.getUserRollNumber());
......
...@@ -2,13 +2,18 @@ ...@@ -2,13 +2,18 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="vertical"
tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.ProfileFragment"> tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.ProfileFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView <de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/user_profile_picture_profile" android:id="@+id/user_profile_picture_profile"
android:layout_width="160dp" android:layout_width="135dp"
android:layout_height="160dp" android:layout_height="99dp"
android:layout_margin="32dp" /> android:layout_margin="32dp" />
<LinearLayout <LinearLayout
...@@ -45,6 +50,39 @@ ...@@ -45,6 +50,39 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="2dp" android:layout_marginBottom="2dp"
android:textSize="16sp" /> android:textSize="16sp" />
</LinearLayout> </LinearLayout>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/role_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@color/colorPrimaryDark">
<android.support.design.widget.TabItem
android:id="@+id/following_tab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Following" />
<android.support.design.widget.TabItem
android:id="@+id/events_tab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Events" />
</android.support.design.widget.TabLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="4dp"
card_view:cardCornerRadius="4dp"
card_view:cardElevation="4dp">
<LinearLayout
android:id="@+id/role_card_layout"
android:layout_width="match_parent"
android:layout_height="80dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/role_card_avatar"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center"
android:scaleType="centerCrop" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_weight="3"
android:orientation="vertical">
<TextView
android:id="@+id/role_card_body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Organization"
android:textColor="@android:color/black"
android:textSize="18sp" />
<TextView
android:id="@+id/role_card_role"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Role" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment