Merge branch 'marijn-appje' into 'master'
Marijn appje See merge request !28
This commit was merged in pull request #28.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package nl.myhyvesbookplus.tagram;
|
package nl.myhyvesbookplus.tagram;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -14,8 +15,15 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.firebase.ui.storage.images.FirebaseImageLoader;
|
import com.firebase.ui.storage.images.FirebaseImageLoader;
|
||||||
|
<<<<<<< HEAD
|
||||||
|
import com.google.android.gms.tasks.OnCompleteListener;
|
||||||
|
import com.google.android.gms.tasks.Task;
|
||||||
|
import com.google.firebase.database.DatabaseReference;
|
||||||
|
import com.google.firebase.database.FirebaseDatabase;
|
||||||
|
=======
|
||||||
import com.google.firebase.auth.FirebaseAuth;
|
import com.google.firebase.auth.FirebaseAuth;
|
||||||
import com.google.firebase.auth.FirebaseUser;
|
import com.google.firebase.auth.FirebaseUser;
|
||||||
|
>>>>>>> origin/master
|
||||||
import com.google.firebase.storage.FirebaseStorage;
|
import com.google.firebase.storage.FirebaseStorage;
|
||||||
import com.google.firebase.storage.StorageReference;
|
import com.google.firebase.storage.StorageReference;
|
||||||
|
|
||||||
@@ -32,11 +40,13 @@ public class TimeLineAdapter extends BaseAdapter implements AdapterView.OnItemCl
|
|||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private ArrayList<UriPost> mData;
|
private ArrayList<UriPost> mData;
|
||||||
|
private DatabaseReference mRef;
|
||||||
|
|
||||||
TimeLineAdapter(Context context, ArrayList<UriPost> data) {
|
TimeLineAdapter(Context context, ArrayList<UriPost> data) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
mData = data;
|
mData = data;
|
||||||
|
mRef = FirebaseDatabase.getInstance().getReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -55,27 +65,37 @@ public class TimeLineAdapter extends BaseAdapter implements AdapterView.OnItemCl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||||
View rowView = mInflater.inflate(R.layout.list_item_timeline, parent, false);
|
View rowView = mInflater.inflate(R.layout.list_item_timeline, parent, false);
|
||||||
|
|
||||||
// TextView userName = (TextView) rowView.findViewById(R.id.username_timeline);
|
// TextView userName = (TextView) rowView.findViewById(R.id.username_timeline);
|
||||||
TextView comment = (TextView) rowView.findViewById(R.id.comment_timeline);
|
TextView comment = (TextView) rowView.findViewById(R.id.comment_timeline);
|
||||||
TextView nietSlechts = (TextView) rowView.findViewById(R.id.niet_slecht_count);
|
final TextView nietSlechts = (TextView) rowView.findViewById(R.id.niet_slecht_count);
|
||||||
|
TextView dateTime = (TextView) rowView.findViewById(R.id.timeline_date);
|
||||||
ImageView photo = (ImageView) rowView.findViewById(R.id.timeline_image);
|
ImageView photo = (ImageView) rowView.findViewById(R.id.timeline_image);
|
||||||
Button nietSlechtButton = (Button) rowView.findViewById(R.id.niet_slecht_button);
|
final ImageButton nietSlechtButton = (ImageButton) rowView.findViewById(R.id.niet_slecht_button);
|
||||||
|
|
||||||
|
final UriPost post = (UriPost) getItem(position);
|
||||||
|
|
||||||
|
nietSlechts.setText(Integer.toString(post.getNietSlechts()));
|
||||||
|
comment.setText(post.getComment());
|
||||||
|
|
||||||
nietSlechtButton.setOnClickListener(new View.OnClickListener() {
|
nietSlechtButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
Log.d(TAG, "onClick: " + position);
|
||||||
|
mRef.child("posts").child(post.getDatabaseEntryName())
|
||||||
|
.child("nietSlechts").setValue(post.getNietSlechts() + 1)
|
||||||
|
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
||||||
|
@Override
|
||||||
|
public void onComplete(@NonNull Task<Void> task) {
|
||||||
|
nietSlechts.setText(Integer.toString(post.getNietSlechts() + 1));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
UriPost post = (UriPost) getItem(position);
|
dateTime.setText(post.getDate().toString());
|
||||||
|
|
||||||
// userName.setText();
|
|
||||||
nietSlechts.setText(Integer.toString(post.getNietSlechts()));
|
|
||||||
comment.setText(post.getComment());
|
|
||||||
|
|
||||||
StorageReference ref = FirebaseStorage.getInstance().getReferenceFromUrl(post.getUri());
|
StorageReference ref = FirebaseStorage.getInstance().getReferenceFromUrl(post.getUri());
|
||||||
Glide.with(mContext)
|
Glide.with(mContext)
|
||||||
@@ -87,7 +107,6 @@ public class TimeLineAdapter extends BaseAdapter implements AdapterView.OnItemCl
|
|||||||
return rowView;
|
return rowView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback method to be invoked when an item in this AdapterView has
|
* Callback method to be invoked when an item in this AdapterView has
|
||||||
* been clicked.
|
* been clicked.
|
||||||
|
|||||||
@@ -42,8 +42,9 @@ public class DownloadClass {
|
|||||||
public void onDataChange(DataSnapshot dataSnapshot) {
|
public void onDataChange(DataSnapshot dataSnapshot) {
|
||||||
|
|
||||||
for (DataSnapshot data : dataSnapshot.getChildren()) {
|
for (DataSnapshot data : dataSnapshot.getChildren()) {
|
||||||
|
UriPost tempPost = data.getValue(UriPost.class);
|
||||||
mList.add(data.getValue(UriPost.class));
|
tempPost.setDatabaseEntryName(data.getKey());
|
||||||
|
mList.add(tempPost);
|
||||||
}
|
}
|
||||||
Collections.reverse(mList);
|
Collections.reverse(mList);
|
||||||
mListener.PostDownloaded();
|
mListener.PostDownloaded();
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import java.util.Date;
|
|||||||
*/
|
*/
|
||||||
public class UriPost extends Post {
|
public class UriPost extends Post {
|
||||||
private String uri;
|
private String uri;
|
||||||
|
private String databaseEntryName;
|
||||||
|
|
||||||
public UriPost() {
|
public UriPost() {
|
||||||
// Default constructor required for calls to DataSnapshot.getValue(UriPost.class)
|
// Default constructor required for calls to DataSnapshot.getValue(UriPost.class)
|
||||||
@@ -33,4 +34,12 @@ public class UriPost extends Post {
|
|||||||
public void setUri(String uri) {
|
public void setUri(String uri) {
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDatabaseEntryName() {
|
||||||
|
return databaseEntryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDatabaseEntryName(String databaseEntryName) {
|
||||||
|
this.databaseEntryName = databaseEntryName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<Space
|
<Space
|
||||||
@@ -20,8 +19,8 @@
|
|||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/timeline_image"
|
android:id="@+id/timeline_image"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_height="250dp"
|
||||||
android:layout_height="250dp" />
|
android:layout_gravity="center" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/comment_timeline"
|
android:id="@+id/comment_timeline"
|
||||||
@@ -30,32 +29,28 @@
|
|||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:text="Hallo Ik ben een comment!" />
|
android:text="Hallo Ik ben een comment!" />
|
||||||
|
|
||||||
<LinearLayout
|
<TextView
|
||||||
|
android:id="@+id/timeline_date"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_horizontal"
|
android:text="date/time" />
|
||||||
android:orientation="horizontal">
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
<Button
|
android:layout_height="40dp">
|
||||||
|
<ImageButton
|
||||||
android:id="@+id/niet_slecht_button"
|
android:id="@+id/niet_slecht_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="200dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent" />
|
||||||
android:text="@string/niet_slecht"/>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
android:text="@string/niet_slecht" />
|
android:text="@string/niet_slecht" />
|
||||||
-->
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/niet_slecht_count"
|
android:id="@+id/niet_slecht_count"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textSize="20dp"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:text="10" />
|
android:text="10" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -30,8 +30,8 @@
|
|||||||
<string name="image_save_error">Foto opslaan mislukt. Zorg a.u.b. dat er genoeg ruimte op uw telefoon beschikbaar is.</string>
|
<string name="image_save_error">Foto opslaan mislukt. Zorg a.u.b. dat er genoeg ruimte op uw telefoon beschikbaar is.</string>
|
||||||
<string name="update_profile_pic_error">Het updaten van de profielfoto is mislukt. Controleer uw internetverbinding.</string>
|
<string name="update_profile_pic_error">Het updaten van de profielfoto is mislukt. Controleer uw internetverbinding.</string>
|
||||||
<string name="upload_profile_pic">Profielfoto aan het uploaden…</string>
|
<string name="upload_profile_pic">Profielfoto aan het uploaden…</string>
|
||||||
|
<string name="niet_slecht">\"\"Niet slecht.\"s: \"</string>
|
||||||
<string name="mail_success">An e-mail was sent, please follow its instructions.</string>
|
<string name="mail_success">An e-mail was sent, please follow its instructions.</string>
|
||||||
<string name="niet_slecht">Niet Slecht.</string>
|
|
||||||
<string name="comment">Bijschrift:</string>
|
<string name="comment">Bijschrift:</string>
|
||||||
<string name="cancel">Annuleer</string>
|
<string name="cancel">Annuleer</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
<string name="profile_picture_description">profile picture</string>
|
<string name="profile_picture_description">profile picture</string>
|
||||||
<string name="change_psw_button">Change Password</string>
|
<string name="change_psw_button">Change Password</string>
|
||||||
<string name="please_wait">Please Wait</string>
|
<string name="please_wait">Please Wait</string>
|
||||||
<string name="niet_slecht">Niet Slecht.</string>
|
<string name="niet_slecht">\"\"Niet slecht.\"s: \"</string>
|
||||||
<string name="upload">Upload</string>
|
<string name="upload">Upload</string>
|
||||||
<string name="save">Save</string>
|
<string name="save">Save</string>
|
||||||
<string name="mail_successful">An e-mail was sent. Please follow its instructions.</string>
|
<string name="mail_successful">An e-mail was sent. Please follow its instructions.</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user