added dialog "displayNote" in explore view
This commit is contained in:
parent
5e23dd9789
commit
9c10a0dc26
3 changed files with 375 additions and 350 deletions
|
@ -1,6 +1,9 @@
|
|||
package com.android_app.matan.ara.sagi.thesocialnotework;
|
||||
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
@ -8,10 +11,16 @@ import android.util.Log;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.volley.Response;
|
||||
|
||||
|
@ -77,6 +86,7 @@ public class ExploreFragment extends Fragment {
|
|||
//Get Views
|
||||
list_notes = (ListView) view.findViewById(R.id.list_notes);
|
||||
noteListAdapter = new ListAdapter(parent, notes);
|
||||
list_notes.setOnItemClickListener(new ItemClickedListener());
|
||||
|
||||
|
||||
dateFilter = (ImageButton) view.findViewById(R.id.explore_date_filter);
|
||||
|
@ -160,7 +170,6 @@ public class ExploreFragment extends Fragment {
|
|||
}
|
||||
|
||||
|
||||
|
||||
public void getAllNotes() throws JSONException {
|
||||
Utils.showLoadingDialog(parent, "Exploring...", "Finding some new interesting notes just for you");
|
||||
Log.d(TAG, "url: " + Utils.BASE_URL + "/note/getPublic");
|
||||
|
@ -194,4 +203,98 @@ public class ExploreFragment extends Fragment {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
// click on listView item
|
||||
class ItemClickedListener implements AdapterView.OnItemClickListener {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
|
||||
//create and configure dialog
|
||||
final Note note = notes.get(position);
|
||||
final Dialog noteViewDialog = new Dialog(getActivity());
|
||||
noteViewDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
noteViewDialog.setContentView(R.layout.note_display_full);
|
||||
// noteViewDialog.setTitle("You wrote...");
|
||||
|
||||
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
|
||||
lp.copyFrom(noteViewDialog.getWindow().getAttributes());
|
||||
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
lp.height = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
noteViewDialog.show();
|
||||
// dialog.getWindow().setAttributes(lp);
|
||||
|
||||
|
||||
//get note_view_full layout elements
|
||||
final TextView title = (TextView) noteViewDialog.findViewById(R.id.ndf_title_textview);
|
||||
final TextView body = (TextView) noteViewDialog.findViewById(R.id.ndf_body_textview);
|
||||
final TextView time = (TextView) noteViewDialog.findViewById(R.id.ndf_time_textview);
|
||||
final TextView date = (TextView) noteViewDialog.findViewById(R.id.ndf_date_textview);
|
||||
final TextView location = (TextView) noteViewDialog.findViewById(R.id.ndf_address_textview);
|
||||
final TextView likes = (TextView) noteViewDialog.findViewById(R.id.ndf_likes_textview);
|
||||
final TextView permission = (TextView) noteViewDialog.findViewById(R.id.ndf_permission_textview);
|
||||
final ImageButton likeBtn = (ImageButton) noteViewDialog.findViewById(R.id.ndf_delete_imagebutton);
|
||||
final ImageView avatar = (RoundAvatarImageView) noteViewDialog.findViewById(R.id.note_user_avatar);
|
||||
final ImageView permission_image = (ImageView) noteViewDialog.findViewById(R.id.permission_image);
|
||||
|
||||
title.setText(note.getTitle());
|
||||
body.setText(note.getBody());
|
||||
date.setText(note.getDate());
|
||||
time.setText(note.getTime());
|
||||
location.setText(note.getAddress());
|
||||
if (likes != null) likes.setText("" + note.getLikes());
|
||||
likeBtn.setBackgroundResource(R.drawable.like_icon);
|
||||
// tags.setText("Tags: "+ note.getTags().toString());
|
||||
// permission.setText("" + (note.isPublic() ? "Public" : "Private"));
|
||||
permission.setVisibility(View.GONE);
|
||||
Utils.URLtoImageView(avatar, note.getAvatar());
|
||||
permission_image.setVisibility(View.GONE);
|
||||
|
||||
likeBtn.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
// //Put up the Yes/No message box
|
||||
// AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
// builder
|
||||
// .setTitle("Delete Note")
|
||||
// .setMessage("Are you sure you want to delete the note?")
|
||||
// .setIcon(android.R.drawable.ic_dialog_alert)
|
||||
// .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
||||
// public void onClick(DialogInterface dialog, int which) {
|
||||
// //Yes button clicked, do something
|
||||
// Toast.makeText(getActivity(), "Item Deleted!",
|
||||
// Toast.LENGTH_SHORT).show();
|
||||
// //TODO send delete
|
||||
// JSONObject delNote = new JSONObject();
|
||||
// try {
|
||||
// delNote.put("uid", userId);
|
||||
// delNote.put("nid", note.getId());
|
||||
// VolleyUtilSingleton.getInstance(getActivity()).post(BASE_URL + "/note/delete", delNote, Utils.deleteNoteSuccessListener, Utils.genericErrorListener);
|
||||
// listOfNotes.remove(presentedNotes.get(position));
|
||||
// presentedNotes.remove(position);
|
||||
//
|
||||
// } catch (JSONException e) {
|
||||
// Toast.makeText(getActivity(), "Something went wrong.\n Failed to delete note...", Toast.LENGTH_LONG).show();
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// updateShowedNotes();
|
||||
//// noteList.setAdapter(noteListAdapter);
|
||||
// noteViewDialog.dismiss();
|
||||
// }
|
||||
// })
|
||||
// .setNegativeButton("No", new DialogInterface.OnClickListener() {
|
||||
// public void onClick(DialogInterface dialog, int which) {
|
||||
// //Yes button clicked, do something
|
||||
// Toast.makeText(getActivity(), "Canceled",
|
||||
// Toast.LENGTH_SHORT).show();
|
||||
// noteViewDialog.dismiss();
|
||||
// }
|
||||
// }) //Do nothing on no
|
||||
// .show();
|
||||
// }
|
||||
// });
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -505,15 +505,6 @@ public class PersonalFragment extends Fragment {
|
|||
public View.OnClickListener button1ClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
|
||||
// Log.d(TAG, "onClick: start");
|
||||
// Log.d(TAG, "onClick: v id: " + v.getId());
|
||||
// Log.d(TAG, "onClick: map_small_filter id: " + R.id.map_small_filter);
|
||||
// Log.d(TAG, "onCreateView: personalSpace_filter_options = " + R.id.personalSpace_filter_options);
|
||||
//
|
||||
// Log.d(TAG, "onClick: are equal? " + (v.getId() == R.id.map_small_filter));
|
||||
//
|
||||
// Log.d(TAG, "onClick: case map_small_filter");
|
||||
//user filters
|
||||
if (userFilterIsVisible) {
|
||||
userFilterSelection = 1;
|
||||
|
@ -549,15 +540,6 @@ public class PersonalFragment extends Fragment {
|
|||
@Override
|
||||
public void onClick(final View v) {
|
||||
|
||||
// Log.d(TAG, "onClick: start");
|
||||
// Log.d(TAG, "onClick: v id: " + v.getId());
|
||||
// Log.d(TAG, "onClick: map_small_filter id: " + R.id.map_small_filter);
|
||||
// Log.d(TAG, "onCreateView: personalSpace_filter_options = " + R.id.personalSpace_filter_options);
|
||||
//
|
||||
// Log.d(TAG, "onClick: are equal? " + (v.getId() == R.id.map_small_filter));
|
||||
//
|
||||
// Log.d(TAG, "onClick: case map_large_filter");
|
||||
|
||||
//user filters
|
||||
if (userFilterIsVisible) {
|
||||
userFilterSelection = 3;
|
||||
|
@ -574,68 +556,6 @@ public class PersonalFragment extends Fragment {
|
|||
}
|
||||
};
|
||||
|
||||
// //all buttons listener
|
||||
// public View.OnClickListener buttonClickListener = new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(final View v) {
|
||||
//
|
||||
// Log.d(TAG, "onClick: start");
|
||||
// Log.d(TAG, "onClick: v id: "+ v.getId());
|
||||
// Log.d(TAG, "onClick: map_small_filter id: "+ R.id.map_small_filter);
|
||||
// Log.d(TAG, "onCreateView: personalSpace_filter_options = "+R.id.personalSpace_filter_options);
|
||||
//
|
||||
// Log.d(TAG, "onClick: are equal? "+ (v.getId() ==R.id.map_small_filter));
|
||||
//
|
||||
// switch (v.getId()) {
|
||||
// case R.id.map_small_filter:
|
||||
// Log.d(TAG, "onClick: case map_small_filter");
|
||||
// //user filters
|
||||
// if (userFilterIsVisible) {
|
||||
// userFilterSelection = 1;
|
||||
// }
|
||||
// //date filters
|
||||
// else {
|
||||
// dateFilterSelection = 86400000L;
|
||||
//
|
||||
// }
|
||||
// updateShowedNotes();
|
||||
// break;
|
||||
// case R.id.map_medium_filter:
|
||||
// Log.d(TAG, "onClick: case map_medium_filter");
|
||||
//
|
||||
// //user filters
|
||||
// if (userFilterIsVisible) {
|
||||
// userFilterSelection = 2;
|
||||
//
|
||||
// }
|
||||
// //date filters
|
||||
// else {
|
||||
// dateFilterSelection = 604800000L;
|
||||
//
|
||||
// }
|
||||
// updateShowedNotes();
|
||||
// break;
|
||||
// case R.id.map_large_filter:
|
||||
// Log.d(TAG, "onClick: case map_large_filter");
|
||||
//
|
||||
// //user filters
|
||||
// if (userFilterIsVisible) {
|
||||
// userFilterSelection = 3;
|
||||
// }
|
||||
// //date filters
|
||||
// else {
|
||||
// dateFilterSelection = 2592000000L;
|
||||
//
|
||||
// }
|
||||
// updateShowedNotes();
|
||||
// break;
|
||||
// default:
|
||||
// Log.d(TAG, "onClick: in default");
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
|
||||
public void updateShowedNotes() {
|
||||
presentedNotes = new ArrayList<>();
|
||||
|
@ -663,7 +583,7 @@ public class PersonalFragment extends Fragment {
|
|||
noteList.setAdapter(noteListAdapter);
|
||||
}
|
||||
|
||||
//set main filter colors
|
||||
//set secondery filter colors filter colors
|
||||
private void setButtonsColor() {
|
||||
|
||||
Log.d(TAG, "setButtonsColor: start");
|
||||
|
|
|
@ -51,7 +51,6 @@ public class SettingsFragment extends Fragment implements View.OnClickListener,
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -122,14 +121,17 @@ public class SettingsFragment extends Fragment implements View.OnClickListener,
|
|||
|
||||
break;
|
||||
case R.id.btn_save:
|
||||
if(txt_password.getText().length() > 3 && txt_email.getText().length() > 0) user.updateUser(parent);
|
||||
else Toast.makeText(parent, "Password should be more than 4 chars long, valid email", Toast.LENGTH_LONG).show();
|
||||
if (txt_password.getText().length() > 3 && txt_email.getText().length() > 0)
|
||||
user.updateUser(parent);
|
||||
else
|
||||
Toast.makeText(parent, "Password should be more than 4 chars long, valid email", Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new camera intent
|
||||
*
|
||||
* @param v
|
||||
*/
|
||||
protected void openCamera(View v) {
|
||||
|
|
Loading…
Reference in a new issue