diff --git a/app/MyHyvesBookPlusStagram/app/src/main/AndroidManifest.xml b/app/MyHyvesBookPlusStagram/app/src/main/AndroidManifest.xml
index 63bdf6e..2284c0c 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/AndroidManifest.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/AndroidManifest.xml
@@ -3,9 +3,8 @@
package="nl.myhyvesbookplus.tagram">
-
-
+
+
mData;
+ private TextView comment;
+ private TextView nietSlechts;
+ private ImageView photo;
+
+ ProfileAdapter(Context context, ArrayList data) {
+ mContext = context;
+ mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ mData = data;
+ }
+
+ @Override
+ public int getCount() {
+ return mData.size();
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return mData.get(position);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View rowView = mInflater.inflate(R.layout.list_item_timeline_profile, parent, false);
+ View newRowView = findViews(rowView);
+ UriPost post = (UriPost) getItem(position);
+ comment.setText(post.getComment());
+ StorageReference ref = FirebaseStorage.getInstance().getReferenceFromUrl(post.getUri());
+ Glide.with(mContext)
+ .using(new FirebaseImageLoader())
+ .load(ref)
+ .into(photo);
+
+ return newRowView;
+ }
+
+ protected View findViews(View rowView) {
+ 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 eb40f3d..4f33ef2 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,12 +9,14 @@ 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;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
+import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
@@ -29,6 +31,7 @@ import com.google.firebase.storage.StorageReference;
import java.io.File;
import java.io.IOException;
+import nl.myhyvesbookplus.tagram.controller.DownloadClass;
import nl.myhyvesbookplus.tagram.controller.ProfilePictureUploader;
import static android.app.Activity.RESULT_OK;
@@ -44,6 +47,8 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
protected ImageView profilePicture;
protected FirebaseUser user;
protected File photoFile = null;
+ private ListView listView;
+ private DownloadClass downloadClass;
ProgressDialog progressDialog;
@@ -55,7 +60,7 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
user = FirebaseAuth.getInstance().getCurrentUser();
- }
+ }
/**
* Assigns all views and buttons.
@@ -81,8 +86,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) {
@@ -100,7 +111,10 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
profilePicture.invalidate();
- return view;
+ downloadClass = new DownloadClass(getActivity());
+ downloadClass.getPostsFromServer();
+
+ return viewTimeline;
}
/**
@@ -131,7 +145,7 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
try {
photoFile = createImageFile();
} catch (IOException ex) {
- Toast.makeText(getActivity(), getString(R.string.image_save_error), Toast.LENGTH_LONG);
+ Toast.makeText(getActivity(), getString(R.string.image_save_error), Toast.LENGTH_LONG).show();
}
if (photoFile != null) {
Uri photoURI = FileProvider.getUriForFile(getActivity(),
@@ -143,6 +157,11 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
}
}
+ public void startList() {
+ ProfileAdapter adapter = new ProfileAdapter(getActivity(), downloadClass.getmList());
+ listView.setAdapter(adapter);
+ }
+
/**
* Grabs the image just taken by the built-in camera and pushes this image to the user account.
* @param requestCode The code which corresponds to REQUEST_TAKE_PHOTO. Used as indicator.
@@ -154,21 +173,20 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
if (requestCode == REQUEST_TAKE_PHOTO && resultCode == RESULT_OK) {
progressDialog = ProgressDialog.show(getActivity(), getString(R.string.please_wait), getString(R.string.upload_profile_pic), false, false);
ProfilePictureUploader profilePictureUploader = new ProfilePictureUploader(getActivity());
- profilePictureUploader.uploadProfilePicture(photoFile.getAbsoluteFile());
+ profilePictureUploader.uploadProfilePicture(photoFile);
}
}
-
private File createImageFile() throws IOException {
// Create an image file name
String imageFileName = "JPEG_" + user.getUid();
File storageDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
- return File.createTempFile(
- imageFileName, /* prefix */
- ".jpg", /* suffix */
- storageDir /* directory */
- );
- }
+ return File.createTempFile(
+ imageFileName, /* prefix */
+ ".jpg", /* suffix */
+ storageDir /* directory */
+ );
+ }
@@ -183,8 +201,8 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
@Override
public void onComplete(@NonNull Task task) {
Toast.makeText(getActivity(), task.isSuccessful()
- ? "An e-mail was sent, please follow its instructions."
- : "An error occurred, please check internet connection.",
+ ? getString(R.string.mail_successful)
+ : getString(R.string.mail_failed),
Toast.LENGTH_SHORT).show();
}
});
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 49697b4..64bf26c 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 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile_header.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile_header.xml
new file mode 100644
index 0000000..562849d
--- /dev/null
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile_header.xml
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile_timeline.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile_timeline.xml
new file mode 100644
index 0000000..fd06e94
--- /dev/null
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile_timeline.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline_profile.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline_profile.xml
new file mode 100644
index 0000000..f8020e8
--- /dev/null
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline_profile.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/values-nl/strings.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/values-nl/strings.xml
index 627e49d..f193b85 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/res/values-nl/strings.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/values-nl/strings.xml
@@ -30,6 +30,7 @@
Foto opslaan mislukt. Zorg a.u.b. dat er genoeg ruimte op uw telefoon beschikbaar is.
Het updaten van de profielfoto is mislukt. Controleer uw internetverbinding.
Profielfoto aan het uploaden…
+ An e-mail was sent, please follow its instructions.
Niet Slecht.
Bijschrift:
Annuleer
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/values/strings.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/values/strings.xml
index 866070f..8909894 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/res/values/strings.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/values/strings.xml
@@ -29,7 +29,7 @@
An error occurred. Please check internet connection.
Saving image to storage failed. Please make sure there is space available on the device.
Updating the profile picture failed. Please check network connection.
- Uploading profile picture...
+ Uploading profile picture…
Comment:
Cancel