diff --git a/app/MyHyvesBookPlusStagram/app/build.gradle b/app/MyHyvesBookPlusStagram/app/build.gradle index 85f6d09..83344be 100644 --- a/app/MyHyvesBookPlusStagram/app/build.gradle +++ b/app/MyHyvesBookPlusStagram/app/build.gradle @@ -6,7 +6,7 @@ android { defaultConfig { applicationId "nl.myhyvesbookplus.tagram" minSdkVersion 21 - targetSdkVersion 25 + targetSdkVersion 21 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 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 7c98ae4..aa8ec14 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 @@ -1,5 +1,6 @@ package nl.myhyvesbookplus.tagram; +import android.app.Fragment; import android.app.FragmentManager; import android.app.FragmentTransaction; import android.content.Intent; @@ -104,11 +105,6 @@ public class MainActivity extends AppCompatActivity implements this.finish(); } -// public void testCreatePost(View view) { -// DownloadClass downloadClass = new DownloadClass(); -// downloadClass.getPosts(); -// } - @Override public void ProfilePictureUpdated(Boolean success) { Log.d(TAG, "ProfilePictureUpdated: Ja ik luister naar je!"); @@ -125,10 +121,11 @@ public class MainActivity extends AppCompatActivity implements @Override public void PostDownloaded() { FragmentManager fragmentManager = getFragmentManager(); - fragmentManager.findFragmentById(R.id.content); - TimelineFragment frag = (TimelineFragment) fragmentManager.findFragmentById(R.id.content); - frag.startList(); + Fragment frag = fragmentManager.findFragmentById(R.id.content); + if (frag instanceof TimelineFragment) { + ((TimelineFragment) frag).startList(); + } } @Override diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/TimeLineAdapter.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/TimeLineAdapter.java index 5cf22f4..6f05305 100644 --- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/TimeLineAdapter.java +++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/TimeLineAdapter.java @@ -5,7 +5,9 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; import android.widget.BaseAdapter; +import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; @@ -22,7 +24,7 @@ import nl.myhyvesbookplus.tagram.model.UriPost; * Created by marijnjansen on 26/06/2017. */ -public class TimeLineAdapter extends BaseAdapter { +public class TimeLineAdapter extends BaseAdapter implements AdapterView.OnItemClickListener { private static final String TAG = "TimeLineAdapter"; private LayoutInflater mInflater; private Context mContext; @@ -55,12 +57,20 @@ public class TimeLineAdapter extends BaseAdapter { View rowView = mInflater.inflate(R.layout.list_item_timeline, parent, false); TextView comment = (TextView) rowView.findViewById(R.id.comment_timeline); - TextView nietslechts = (TextView) rowView.findViewById(R.id.niet_slecht_count); + TextView nietSlechts = (TextView) rowView.findViewById(R.id.niet_slecht_count); ImageView photo = (ImageView) rowView.findViewById(R.id.timeline_image); + ImageButton nietSlechtButton = (ImageButton) rowView.findViewById(R.id.niet_slecht_button); + + nietSlechtButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }); UriPost post = (UriPost) getItem(position); - nietslechts.setText(Integer.toString(post.getNietSlechts())); + nietSlechts.setText(Integer.toString(post.getNietSlechts())); comment.setText(post.getComment()); StorageReference ref = FirebaseStorage.getInstance().getReferenceFromUrl(post.getUri()); @@ -72,4 +82,24 @@ public class TimeLineAdapter extends BaseAdapter { return rowView; } + + + /** + * Callback method to be invoked when an item in this AdapterView has + * been clicked. + *
+ * Implementers can call getItemAtPosition(position) if they need
+ * to access the data associated with the selected item.
+ *
+ * @param parent The AdapterView where the click happened.
+ * @param view The view within the AdapterView that was clicked (this
+ * will be a view provided by the adapter)
+ * @param position The position of the view in the adapter.
+ * @param id The row id of the item that was clicked.
+ */
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ Log.d(TAG, "onItemClick: rowNumber! "+ position);
+ }
+
}
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/TimelineFragment.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/TimelineFragment.java
index 44f568d..b2ca6d4 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/TimelineFragment.java
+++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/TimelineFragment.java
@@ -10,13 +10,7 @@ import android.widget.ListView;
import nl.myhyvesbookplus.tagram.controller.DownloadClass;
-/**
- * A simple {@link Fragment} subclass.
- * Use the {@link TimelineFragment#newInstance} factory method to
- * create an instance of this fragment.
- */
public class TimelineFragment extends Fragment {
- final private static String TAG = "TimelineFragment";
private ListView listView;
private DownloadClass downloadClass;
@@ -25,29 +19,15 @@ public class TimelineFragment extends Fragment {
// Required empty public constructor
}
- /**
- * Use this factory method to create a new instance of
- * this fragment using the provided parameters.
- * @return A new instance of fragment TimelineFragment.
- */
- // TODO: Rename and change types and number of parameters
- public static TimelineFragment newInstance() {
- TimelineFragment fragment = new TimelineFragment();
- Bundle args = new Bundle();
- fragment.setArguments(args);
- return fragment;
- }
-
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_timeline, container, false);
-
listView = (ListView) view.findViewById(R.id.listview);
+
downloadClass = new DownloadClass(getActivity());
downloadClass.getPostsFromServer();
- // Inflate the layout for this fragment
return view;
}
diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline.xml
index 5a0d59e..9e1bba4 100644
--- a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline.xml
+++ b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/list_item_timeline.xml
@@ -2,6 +2,7 @@