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;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -14,8 +15,15 @@ import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
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.FirebaseUser;
|
||||
>>>>>>> origin/master
|
||||
import com.google.firebase.storage.FirebaseStorage;
|
||||
import com.google.firebase.storage.StorageReference;
|
||||
|
||||
@@ -32,11 +40,13 @@ public class TimeLineAdapter extends BaseAdapter implements AdapterView.OnItemCl
|
||||
private LayoutInflater mInflater;
|
||||
private Context mContext;
|
||||
private ArrayList<UriPost> mData;
|
||||
private DatabaseReference mRef;
|
||||
|
||||
TimeLineAdapter(Context context, ArrayList<UriPost> data) {
|
||||
mContext = context;
|
||||
mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
mData = data;
|
||||
mRef = FirebaseDatabase.getInstance().getReference();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,27 +65,37 @@ public class TimeLineAdapter extends BaseAdapter implements AdapterView.OnItemCl
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
// TextView userName = (TextView) rowView.findViewById(R.id.username_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);
|
||||
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() {
|
||||
@Override
|
||||
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);
|
||||
|
||||
// userName.setText();
|
||||
nietSlechts.setText(Integer.toString(post.getNietSlechts()));
|
||||
comment.setText(post.getComment());
|
||||
dateTime.setText(post.getDate().toString());
|
||||
|
||||
StorageReference ref = FirebaseStorage.getInstance().getReferenceFromUrl(post.getUri());
|
||||
Glide.with(mContext)
|
||||
@@ -87,7 +107,6 @@ public class TimeLineAdapter extends BaseAdapter implements AdapterView.OnItemCl
|
||||
return rowView;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Callback method to be invoked when an item in this AdapterView has
|
||||
* been clicked.
|
||||
|
||||
@@ -42,8 +42,9 @@ public class DownloadClass {
|
||||
public void onDataChange(DataSnapshot dataSnapshot) {
|
||||
|
||||
for (DataSnapshot data : dataSnapshot.getChildren()) {
|
||||
|
||||
mList.add(data.getValue(UriPost.class));
|
||||
UriPost tempPost = data.getValue(UriPost.class);
|
||||
tempPost.setDatabaseEntryName(data.getKey());
|
||||
mList.add(tempPost);
|
||||
}
|
||||
Collections.reverse(mList);
|
||||
mListener.PostDownloaded();
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.Date;
|
||||
*/
|
||||
public class UriPost extends Post {
|
||||
private String uri;
|
||||
private String databaseEntryName;
|
||||
|
||||
public UriPost() {
|
||||
// Default constructor required for calls to DataSnapshot.getValue(UriPost.class)
|
||||
@@ -33,4 +34,12 @@ public class UriPost extends Post {
|
||||
public void setUri(String 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"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Space
|
||||
@@ -20,8 +19,8 @@
|
||||
<ImageView
|
||||
android:id="@+id/timeline_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_height="250dp" />
|
||||
android:layout_height="250dp"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/comment_timeline"
|
||||
@@ -30,32 +29,28 @@
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="Hallo Ik ben een comment!" />
|
||||
|
||||
<LinearLayout
|
||||
<TextView
|
||||
android:id="@+id/timeline_date"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:text="date/time" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp">
|
||||
<ImageButton
|
||||
android:id="@+id/niet_slecht_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/niet_slecht"/>
|
||||
|
||||
<!--
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="match_parent" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="@string/niet_slecht" />
|
||||
-->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/niet_slecht_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:textSize="20dp"
|
||||
android:padding="10dp"
|
||||
android:text="10" />
|
||||
</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="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="niet_slecht">\"\"Niet slecht.\"s: \"</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="cancel">Annuleer</string>
|
||||
</resources>
|
||||
@@ -22,7 +22,7 @@
|
||||
<string name="profile_picture_description">profile picture</string>
|
||||
<string name="change_psw_button">Change Password</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="save">Save</string>
|
||||
<string name="mail_successful">An e-mail was sent. Please follow its instructions.</string>
|
||||
|
||||
Reference in New Issue
Block a user