Commit 5cdfecd7 authored by Varun Patil's avatar Varun Patil

Get a minimal Body Fragment working

parent f5dd48aa
......@@ -68,9 +68,9 @@ public class BodyCardFragment extends Fragment {
public void onStart() {
super.onStart();
LinearLayout linearLayout = (LinearLayout) getView().findViewById(R.id.body_card_layout);
ImageView bodyAvatar = (ImageView) getView().findViewById(R.id.body_avatar);
TextView bodyName = (TextView) getView().findViewById(R.id.body_name);
TextView bodyDescription = (TextView) getView().findViewById(R.id.body_description);
ImageView bodyAvatar = (ImageView) getView().findViewById(R.id.body_card_avatar);
TextView bodyName = (TextView) getView().findViewById(R.id.body_card_name);
TextView bodyDescription = (TextView) getView().findViewById(R.id.body_card_description);
bodyName.setText(body.getBodyName());
bodyDescription.setText(body.getBodyShortDescription());
......@@ -80,7 +80,7 @@ public class BodyCardFragment extends Fragment {
@Override
public void onClick(View view) {
/* Show the next fragment and destroy the page */
BodyFragment bodyFragment = BodyFragment.newInstance("Dummy", "Dummy");
BodyFragment bodyFragment = BodyFragment.newInstance(body);
bodyFragment.setArguments(getArguments());
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
ft.replace(R.id.framelayout_for_fragment, bodyFragment, bodyFragment.getTag());
......
......@@ -6,8 +6,12 @@ import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.google.gson.Gson;
import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.data.Body;
/**
* A simple {@link Fragment} subclass.
......@@ -17,14 +21,12 @@ import in.ac.iitb.gymkhana.iitbapp.R;
public class BodyFragment extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
private static final String ARG_BODY = "body";
String TAG = "BodyFragment";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private Body body;
public BodyFragment() {
......@@ -35,16 +37,14 @@ public class BodyFragment extends Fragment {
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @param arg_body Body for details
* @return A new instance of fragment BodyFragment.
*/
// TODO: Rename and change types and number of parameters
public static BodyFragment newInstance(String param1, String param2) {
public static BodyFragment newInstance(Body arg_body) {
BodyFragment fragment = new BodyFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
args.putString(ARG_BODY, new Gson().toJson(arg_body));
fragment.setArguments(args);
return fragment;
}
......@@ -53,11 +53,19 @@ public class BodyFragment extends Fragment {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
body = new Gson().fromJson(getArguments().getString(ARG_BODY), Body.class);
}
}
@Override
public void onStart() {
super.onStart();
TextView bodyName = (TextView) getView().findViewById(R.id.body_name);
bodyName.setText(body.getBodyName());
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
......
......@@ -7,6 +7,7 @@
<!-- TODO: Update blank fragment layout -->
<TextView
android:id="@+id/body_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
......
......@@ -17,7 +17,7 @@
android:orientation="horizontal">
<ImageView
android:id="@+id/body_avatar"
android:id="@+id/body_card_avatar"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center"
......@@ -33,7 +33,7 @@
android:orientation="vertical">
<TextView
android:id="@+id/body_name"
android:id="@+id/body_card_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Organization"
......@@ -41,7 +41,7 @@
android:textSize="18sp" />
<TextView
android:id="@+id/body_description"
android:id="@+id/body_card_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Description" />
......
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