Working profile page with Adapter. Need Marijn to fix the downloadclass to show user-only content instead of entire timeline.
This commit is contained in:
@@ -122,8 +122,11 @@ public class MainActivity extends AppCompatActivity implements
|
|||||||
public void PostDownloaded() {
|
public void PostDownloaded() {
|
||||||
FragmentManager fragmentManager = getFragmentManager();
|
FragmentManager fragmentManager = getFragmentManager();
|
||||||
Fragment frag = fragmentManager.findFragmentById(R.id.content);
|
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();
|
((TimelineFragment) frag).startList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ public class ProfileAdapter extends BaseAdapter {
|
|||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private ArrayList<UriPost> mData;
|
private ArrayList<UriPost> mData;
|
||||||
protected TextView comment;
|
private TextView comment;
|
||||||
protected TextView nietSlechts;
|
private TextView nietSlechts;
|
||||||
protected ImageView photo;
|
private ImageView photo;
|
||||||
|
|
||||||
ProfileAdapter(Context context, ArrayList<UriPost> data) {
|
ProfileAdapter(Context context, ArrayList<UriPost> data) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
@@ -74,5 +74,6 @@ public class ProfileAdapter extends BaseAdapter {
|
|||||||
comment = (TextView) rowView.findViewById(R.id.comment_timeline_profile);
|
comment = (TextView) rowView.findViewById(R.id.comment_timeline_profile);
|
||||||
nietSlechts = (TextView) rowView.findViewById(R.id.niet_slecht_count_profile);
|
nietSlechts = (TextView) rowView.findViewById(R.id.niet_slecht_count_profile);
|
||||||
photo = (ImageView) rowView.findViewById(R.id.timeline_image_profile);
|
photo = (ImageView) rowView.findViewById(R.id.timeline_image_profile);
|
||||||
|
return rowView;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import android.os.Environment;
|
|||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.content.FileProvider;
|
import android.support.v4.content.FileProvider;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
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);
|
profilePicture = (ImageView) view.findViewById(R.id.imageView_profile_picture);
|
||||||
profileName = (TextView) view.findViewById(R.id.profile_name);
|
profileName = (TextView) view.findViewById(R.id.profile_name);
|
||||||
changePwdButton = (Button) view.findViewById(R.id.change_psw_button);
|
changePwdButton = (Button) view.findViewById(R.id.change_psw_button);
|
||||||
listView = (ListView) view.findViewById(R.id.listview);
|
|
||||||
bindOnClick();
|
bindOnClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,8 +87,14 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.fragment_profile, container, false);
|
View viewTimeline = inflater.inflate(R.layout.fragment_profile_timeline, container, false);
|
||||||
findViews(view);
|
|
||||||
|
|
||||||
|
|
||||||
|
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 != null) {
|
||||||
if(user.getPhotoUrl() != null) {
|
if(user.getPhotoUrl() != null) {
|
||||||
@@ -105,10 +111,11 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
profilePicture.invalidate();
|
profilePicture.invalidate();
|
||||||
|
|
||||||
downloadClass = new DownloadClass(getActivity());
|
downloadClass = new DownloadClass(getActivity());
|
||||||
downloadClass.getPostsFromServer();
|
downloadClass.getPostsFromServer();
|
||||||
|
|
||||||
return view;
|
return viewTimeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -153,8 +160,13 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
|
|
||||||
public void startList() {
|
public void startList() {
|
||||||
ProfileAdapter adapter = new ProfileAdapter(getActivity(), downloadClass.getmList());
|
ProfileAdapter adapter = new ProfileAdapter(getActivity(), downloadClass.getmList());
|
||||||
listView.setAdapter(adapter);
|
if (listView != null) {
|
||||||
listView.addHeaderView(adapter);
|
listView.setAdapter(adapter);
|
||||||
|
} else {
|
||||||
|
Log.d("Jemoeder", "startList: Halloooooooo");
|
||||||
|
}
|
||||||
|
|
||||||
|
// listView.addHeaderView(adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -40,8 +40,10 @@ public class DownloadClass {
|
|||||||
mDataRef.child("posts").addListenerForSingleValueEvent(new ValueEventListener() {
|
mDataRef.child("posts").addListenerForSingleValueEvent(new ValueEventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDataChange(DataSnapshot dataSnapshot) {
|
public void onDataChange(DataSnapshot dataSnapshot) {
|
||||||
|
|
||||||
for (DataSnapshot data : dataSnapshot.getChildren()) {
|
for (DataSnapshot data : dataSnapshot.getChildren()) {
|
||||||
mList.add(data.getValue(UriPost.class));
|
|
||||||
|
mList.add(data.getValue(UriPost.class));
|
||||||
}
|
}
|
||||||
Collections.reverse(mList);
|
Collections.reverse(mList);
|
||||||
mListener.PostDownloaded();
|
mListener.PostDownloaded();
|
||||||
|
|||||||
@@ -1,81 +0,0 @@
|
|||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:context="nl.myhyvesbookplus.tagram.ProfileFragment">
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<Space
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="5dp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/profile_name"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:text="Name:"
|
|
||||||
android:textSize="25sp"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<Space
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="10dp" />
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/profile_pic_button"
|
|
||||||
android:layout_width="60dp"
|
|
||||||
android:layout_height="80dp"
|
|
||||||
android:layout_marginStart="110dp"
|
|
||||||
android:background="@android:color/transparent"
|
|
||||||
android:elevation="1dp"
|
|
||||||
app:srcCompat="@android:drawable/ic_menu_camera" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/imageView_profile_picture"
|
|
||||||
android:contentDescription="@string/profile_picture_description"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="300dp"
|
|
||||||
app:srcCompat="@drawable/avatar_standard"
|
|
||||||
android:layout_marginTop="-70dp"/>
|
|
||||||
|
|
||||||
<Space
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="25dp" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/change_psw_button"
|
|
||||||
android:layout_width="300dp"
|
|
||||||
android:layout_height="50dp"
|
|
||||||
android:background="?attr/colorPrimary"
|
|
||||||
android:text="@string/change_psw_button"
|
|
||||||
android:textColor="@android:color/white"
|
|
||||||
android:textSize="16sp" />
|
|
||||||
|
|
||||||
<Space
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="20dp" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/logout_button"
|
|
||||||
android:layout_width="300dp"
|
|
||||||
android:layout_height="50dp"
|
|
||||||
android:background="?attr/colorPrimary"
|
|
||||||
android:onClick="logOutOnClick"
|
|
||||||
android:text="@string/logout_button"
|
|
||||||
android:textColor="@android:color/white"
|
|
||||||
android:textSize="16sp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</ScrollView>
|
|
||||||
</FrameLayout>
|
|
||||||
@@ -65,5 +65,12 @@
|
|||||||
android:text="@string/logout_button"
|
android:text="@string/logout_button"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp" />
|
||||||
|
<Space
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="10dp" />
|
||||||
|
<Space
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="10dp" />
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
Reference in New Issue
Block a user