diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/MainActivity.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/MainActivity.java index aa8ec14..8772d76 100644 --- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/MainActivity.java +++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/MainActivity.java @@ -122,8 +122,11 @@ public class MainActivity extends AppCompatActivity implements public void PostDownloaded() { FragmentManager fragmentManager = getFragmentManager(); Fragment frag = fragmentManager.findFragmentById(R.id.content); + Log.d(TAG, "PostDownloaded: " + R.id.content); - if (frag instanceof TimelineFragment) { + if (frag instanceof ProfileFragment) { + ((ProfileFragment) frag).startList(); + } else if (frag instanceof TimelineFragment) { ((TimelineFragment) frag).startList(); } } diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileAdapter.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileAdapter.java index faa15ea..357876a 100644 --- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileAdapter.java +++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileAdapter.java @@ -30,9 +30,9 @@ public class ProfileAdapter extends BaseAdapter { private LayoutInflater mInflater; private Context mContext; private ArrayList mData; - protected TextView comment; - protected TextView nietSlechts; - protected ImageView photo; + private TextView comment; + private TextView nietSlechts; + private ImageView photo; ProfileAdapter(Context context, ArrayList data) { mContext = context; @@ -74,5 +74,6 @@ public class ProfileAdapter extends BaseAdapter { comment = (TextView) rowView.findViewById(R.id.comment_timeline_profile); nietSlechts = (TextView) rowView.findViewById(R.id.niet_slecht_count_profile); photo = (ImageView) rowView.findViewById(R.id.timeline_image_profile); + return rowView; } } diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java index 056b8b2..73c0388 100644 --- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java +++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java @@ -9,6 +9,7 @@ import android.os.Environment; import android.provider.MediaStore; import android.support.annotation.NonNull; import android.support.v4.content.FileProvider; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -70,7 +71,6 @@ public class ProfileFragment extends Fragment implements View.OnClickListener { profilePicture = (ImageView) view.findViewById(R.id.imageView_profile_picture); profileName = (TextView) view.findViewById(R.id.profile_name); changePwdButton = (Button) view.findViewById(R.id.change_psw_button); - listView = (ListView) view.findViewById(R.id.listview); bindOnClick(); } @@ -87,8 +87,14 @@ public class ProfileFragment extends Fragment implements View.OnClickListener { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_profile, container, false); - findViews(view); + View viewTimeline = inflater.inflate(R.layout.fragment_profile_timeline, container, false); + + + + listView = (ListView) viewTimeline.findViewById(R.id.listview_profile); + View viewHeader = inflater.inflate(R.layout.fragment_profile_header, listView, false); + findViews(viewHeader); + listView.addHeaderView(viewHeader); if (user != null) { if(user.getPhotoUrl() != null) { @@ -105,10 +111,11 @@ public class ProfileFragment extends Fragment implements View.OnClickListener { } profilePicture.invalidate(); + downloadClass = new DownloadClass(getActivity()); downloadClass.getPostsFromServer(); - return view; + return viewTimeline; } /** @@ -153,8 +160,13 @@ public class ProfileFragment extends Fragment implements View.OnClickListener { public void startList() { ProfileAdapter adapter = new ProfileAdapter(getActivity(), downloadClass.getmList()); - listView.setAdapter(adapter); - listView.addHeaderView(adapter); + if (listView != null) { + listView.setAdapter(adapter); + } else { + Log.d("Jemoeder", "startList: Halloooooooo"); + } + +// listView.addHeaderView(adapter); } /** diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/controller/DownloadClass.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/controller/DownloadClass.java index a32a97c..d589360 100644 --- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/controller/DownloadClass.java +++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/controller/DownloadClass.java @@ -40,8 +40,10 @@ public class DownloadClass { mDataRef.child("posts").addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { + for (DataSnapshot data : dataSnapshot.getChildren()) { - mList.add(data.getValue(UriPost.class)); + + mList.add(data.getValue(UriPost.class)); } Collections.reverse(mList); mListener.PostDownloaded(); diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile.xml deleted file mode 100644 index 8e04ad4..0000000 --- a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - - - - - -