Commit c59240c2 authored by 9731301's avatar 9731301

add a entity for calender to save data

parent fc7aee34
package com.example.mynotepad; package com.example.mynotepad;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.room.Room;
import android.os.Bundle; import android.os.Bundle;
import android.view.Gravity; import android.view.Gravity;
...@@ -9,15 +10,17 @@ import android.widget.ImageView; ...@@ -9,15 +10,17 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.example.mynotepad.Menu.CustomMenu; import com.example.mynotepad.Menu.CustomMenu;
import com.example.mynotepad.MenuFeatures.AllNotes.NotesDataBase.NoteDataBase;
import com.example.mynotepad.MenuFeatures.Information.InfoClickListener; import com.example.mynotepad.MenuFeatures.Information.InfoClickListener;
import com.example.mynotepad.MenuFeatures.Information.Information; import com.example.mynotepad.MenuFeatures.Information.Information;
public class MainActivity extends AppCompatActivity implements View.OnClickListener { public class MainActivity extends AppCompatActivity implements View.OnClickListener {
ImageView toolbarListImg; private ImageView toolbarListImg;
CustomMenu customMenu; private CustomMenu customMenu;
TextView wlcTxt; private TextView wlcTxt;
Information informationView; private Information informationView;
public static NoteDataBase noteDataBase;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -37,6 +40,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe ...@@ -37,6 +40,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
} }
private void init() { private void init() {
noteDataBase = Room.databaseBuilder(this, NoteDataBase.class, "RoomDb").allowMainThreadQueries().build();
customMenu = findViewById(R.id.mainListItem); customMenu = findViewById(R.id.mainListItem);
customMenu.setVisibility(customMenu.GONE); customMenu.setVisibility(customMenu.GONE);
wlcTxt = findViewById(R.id.wlcTxt); wlcTxt = findViewById(R.id.wlcTxt);
......
...@@ -15,6 +15,7 @@ import android.widget.FrameLayout; ...@@ -15,6 +15,7 @@ import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import com.example.mynotepad.MainActivity;
import com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.MyAllNotesAdaptor; import com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.MyAllNotesAdaptor;
import com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.MyNote; import com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.MyNote;
import com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.OnAllNotesItemClickListener; import com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView.OnAllNotesItemClickListener;
...@@ -29,6 +30,8 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton; ...@@ -29,6 +30,8 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static com.example.mynotepad.MainActivity.noteDataBase;
public class AllNotesActivity extends AppCompatActivity { public class AllNotesActivity extends AppCompatActivity {
private FrameLayout fragPlace; private FrameLayout fragPlace;
...@@ -39,10 +42,9 @@ public class AllNotesActivity extends AppCompatActivity { ...@@ -39,10 +42,9 @@ public class AllNotesActivity extends AppCompatActivity {
private FrameLayout allNoteToolBar; private FrameLayout allNoteToolBar;
private RecyclerView recyclerView; private RecyclerView recyclerView;
private MyAllNotesAdaptor myAdaptor; private MyAllNotesAdaptor myAdaptor;
private List<Note> notes; private List<Note> entityNotes;
private List<MyNote> myNotes; private List<MyNote> myNotes;
public static MyNote myChosenNote; public static MyNote myChosenNote;
public static NoteDataBase noteDataBase;
@Override @Override
...@@ -53,8 +55,7 @@ public class AllNotesActivity extends AppCompatActivity { ...@@ -53,8 +55,7 @@ public class AllNotesActivity extends AppCompatActivity {
} }
private void init() { private void init() {
// get data from database // get data from databas
noteDataBase = Room.databaseBuilder(this, NoteDataBase.class, "RoomDb").allowMainThreadQueries().build();
setAllNoteListAndTitles(); setAllNoteListAndTitles();
customToolbarOption = findViewById(R.id.customToolbarOption); customToolbarOption = findViewById(R.id.customToolbarOption);
...@@ -79,7 +80,6 @@ public class AllNotesActivity extends AppCompatActivity { ...@@ -79,7 +80,6 @@ public class AllNotesActivity extends AppCompatActivity {
} }
public void addListeners() { public void addListeners() {
addNoteButton.setOnClickListener(new View.OnClickListener() { addNoteButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
...@@ -88,7 +88,7 @@ public class AllNotesActivity extends AppCompatActivity { ...@@ -88,7 +88,7 @@ public class AllNotesActivity extends AppCompatActivity {
} }
}); });
// add listener to recyclerView // add listener to recyclerView
myAdaptor.setOnItemClickListener(new OnAllNotesItemClickListener() { myAdaptor.setOnItemClickListener(new OnAllNotesItemClickListener() {
@Override @Override
public void onItemClicked(MyNote myNote) { public void onItemClicked(MyNote myNote) {
...@@ -119,46 +119,59 @@ public class AllNotesActivity extends AppCompatActivity { ...@@ -119,46 +119,59 @@ public class AllNotesActivity extends AppCompatActivity {
customToolbarOption.setCustomToolbarOptionListener(new CustomToolbarOptionListener() { customToolbarOption.setCustomToolbarOptionListener(new CustomToolbarOptionListener() {
@Override @Override
public void onStarClicked(ImageView yellowS, ImageView blackS) { public void onStarClicked(ImageView yellowS, ImageView blackS) {
if (yellowS.getVisibility() == View.VISIBLE){ starClicked(yellowS, blackS);
yellowS.setVisibility(View.GONE);
blackS.setVisibility(View.VISIBLE);
myChosenNote.setAchieved(false);
}
else {
yellowS.setVisibility(View.VISIBLE);
blackS.setVisibility(View.GONE);
myChosenNote.setAchieved(true);
}
} }
@Override @Override
public void onDeleteClicked(final ImageView imageView) { public void onDeleteClicked(final ImageView imageView) {
AlertDialog.Builder alert = new AlertDialog.Builder(AllNotesActivity.this); deleteClicked(imageView);
alert.setMessage("are you sure you wanna delete it ??? ");
alert.setPositiveButton("yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
noteDataBase.noteDao().deleteNote(notes.get(myNotes.indexOf(myChosenNote)));
init();
}
});
alert.setNegativeButton("no", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.cancel();
}
});
alert.show();
} }
@Override @Override
public void onCloseClicked(ImageView imageView ) { public void onCloseClicked() {
customToolbarOption.setVisibility(View.GONE); closeClicked();
allNoteToolBar.setVisibility(View.VISIBLE);
} }
}); });
} }
private void closeClicked() {
customToolbarOption.setVisibility(View.GONE);
allNoteToolBar.setVisibility(View.VISIBLE);
}
private void deleteClicked(ImageView imageView) {
AlertDialog.Builder alert = new AlertDialog.Builder(AllNotesActivity.this);
alert.setMessage("are you sure you wanna delete it ??? ");
alert.setPositiveButton("yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
noteDataBase.noteDao().deleteNote(entityNotes.get(myNotes.indexOf(myChosenNote)));
init();
}
});
alert.setNegativeButton("no", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.cancel();
}
});
alert.show();
allNoteToolBar.setVisibility(View.VISIBLE);
}
private void starClicked(ImageView yellowS, ImageView blackS) {
if (yellowS.getVisibility() == View.VISIBLE) {
yellowS.setVisibility(View.GONE);
blackS.setVisibility(View.VISIBLE);
myChosenNote.setAchieved(false);
} else {
yellowS.setVisibility(View.VISIBLE);
blackS.setVisibility(View.GONE);
myChosenNote.setAchieved(true);
}
}
private void showAddAlert() { private void showAddAlert() {
final AlertDialog.Builder alert = new AlertDialog.Builder(this); final AlertDialog.Builder alert = new AlertDialog.Builder(this);
...@@ -197,9 +210,9 @@ public class AllNotesActivity extends AppCompatActivity { ...@@ -197,9 +210,9 @@ public class AllNotesActivity extends AppCompatActivity {
private void setAllNoteListAndTitles() { private void setAllNoteListAndTitles() {
notes = noteDataBase.noteDao().getAll(); entityNotes = noteDataBase.noteDao().getAll();
myNotes = new ArrayList<>(); myNotes = new ArrayList<>();
for (Note note : notes) { for (Note note : entityNotes) {
MyNote myNote = new MyNote(note.getTitle(), note.getDescription(), note.isAchieved()); MyNote myNote = new MyNote(note.getTitle(), note.getDescription(), note.isAchieved());
myNotes.add(myNote); myNotes.add(myNote);
} }
......
...@@ -19,6 +19,8 @@ import com.example.mynotepad.MenuFeatures.AllNotes.NotesDataBase.Note; ...@@ -19,6 +19,8 @@ import com.example.mynotepad.MenuFeatures.AllNotes.NotesDataBase.Note;
import com.example.mynotepad.R; import com.example.mynotepad.R;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import static com.example.mynotepad.MainActivity.noteDataBase;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
* create an instance of this fragment. * create an instance of this fragment.
...@@ -85,7 +87,7 @@ public class NoteFragment extends Fragment { ...@@ -85,7 +87,7 @@ public class NoteFragment extends Fragment {
private void saveNote() { private void saveNote() {
note = new Note(titleTxt.getText().toString(), bodyTxt.getText().toString(), false); note = new Note(titleTxt.getText().toString(), bodyTxt.getText().toString(), false);
AllNotesActivity.noteDataBase.noteDao().insertNote(note); noteDataBase.noteDao().insertNote(note);
} }
......
package com.example.mynotepad.MenuFeatures.AllNotes.NotesDataBase;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
@Entity
public class DateEntity {
@PrimaryKey(autoGenerate = true)
int ID;
@ColumnInfo(name = "date")
String date ;
@ColumnInfo(name = "description")
String description;
@ColumnInfo(name = "achieved")
boolean isAchieved;
public DateEntity(String date , String description , boolean isAchieved){
this.date = date;
this.description = description;
this.isAchieved = isAchieved;
}
public int getID() {
return ID;
}
public String getDate() {
return date;
}
public String getDescription() {
return description;
}
public boolean isAchieved(){
return isAchieved;
}
}
\ No newline at end of file
package com.example.mynotepad.MenuFeatures.AllNotes.NotesDataBase;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;
import java.util.List;
@Dao
public interface DateNoreDAO {
// a method list type
@Query("SELECT * FROM DateEntity")
List<DateEntity> getAllDateNotes();
//insert data in database
@Insert
void insertDateNote(DateEntity dateEntity);
@Delete
void deleteDateNote(DateEntity dateEntity);
@Update
void updateDateNote(DateEntity dateEntity);
}
...@@ -25,4 +25,5 @@ public interface NoteDAO { ...@@ -25,4 +25,5 @@ public interface NoteDAO {
@Update @Update
void updateNote(Note note); void updateNote(Note note);
} }
\ No newline at end of file
...@@ -3,8 +3,9 @@ package com.example.mynotepad.MenuFeatures.AllNotes.NotesDataBase; ...@@ -3,8 +3,9 @@ package com.example.mynotepad.MenuFeatures.AllNotes.NotesDataBase;
import androidx.room.Database; import androidx.room.Database;
import androidx.room.RoomDatabase; import androidx.room.RoomDatabase;
@Database(entities = Note.class, version = 1) @Database(entities = {Note.class, DateEntity.class},version = 1)
public abstract class NoteDataBase extends RoomDatabase { public abstract class NoteDataBase extends RoomDatabase {
public abstract NoteDAO noteDao(); public abstract NoteDAO noteDao();
public abstract DateNoreDAO dateNoreDAO();
} }
...@@ -4,23 +4,33 @@ import androidx.appcompat.app.AppCompatActivity; ...@@ -4,23 +4,33 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import com.example.mynotepad.MenuFeatures.AllNotes.Note.NoteFragment;
import com.example.mynotepad.MenuFeatures.AllNotes.NotesDataBase.DateEntity;
import com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.MyCalenderAdaptor; import com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.MyCalenderAdaptor;
import com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.OnCalenderItemClickListener;
import com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.TimePicker.DatePickerActivity; import com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.TimePicker.DatePickerActivity;
import com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.TimePicker.MyDate; import com.example.mynotepad.MenuFeatures.Calender.MyCalenderRecyclerView.TimePicker.MyDate;
import com.example.mynotepad.MenuFeatures.CustomToolbarOption; import com.example.mynotepad.MenuFeatures.CustomToolbarOption;
import com.example.mynotepad.MenuFeatures.CustomToolbarOptionListener;
import com.example.mynotepad.R; import com.example.mynotepad.R;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class MyCalenderActivity extends AppCompatActivity implements View.OnClickListener { import static com.example.mynotepad.MainActivity.noteDataBase;
public class MyCalenderActivity extends AppCompatActivity {
private FloatingActionButton addDateBtn; private FloatingActionButton addDateBtn;
private CustomToolbarOption customToolbarOption; private CustomToolbarOption customToolbarOption;
...@@ -30,6 +40,8 @@ public class MyCalenderActivity extends AppCompatActivity implements View.OnClic ...@@ -30,6 +40,8 @@ public class MyCalenderActivity extends AppCompatActivity implements View.OnClic
private RecyclerView recyclerView; private RecyclerView recyclerView;
private MyCalenderAdaptor myAdaptor; private MyCalenderAdaptor myAdaptor;
private List<MyDate> myDates; private List<MyDate> myDates;
private List<DateEntity> entityDates;
private MyDate myChosenDateNote;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -38,6 +50,12 @@ public class MyCalenderActivity extends AppCompatActivity implements View.OnClic ...@@ -38,6 +50,12 @@ public class MyCalenderActivity extends AppCompatActivity implements View.OnClic
init(); init();
} }
@Override
protected void onResume() {
super.onResume();
init();
}
private void init() { private void init() {
setAllNoteListAndTitles(); setAllNoteListAndTitles();
...@@ -64,18 +82,101 @@ public class MyCalenderActivity extends AppCompatActivity implements View.OnClic ...@@ -64,18 +82,101 @@ public class MyCalenderActivity extends AppCompatActivity implements View.OnClic
} }
private void addListeners() { private void addListeners() {
addDateBtn.setOnClickListener(this); addDateBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
addNewDateAndDescription();
}
});
// add listener to recyclerView
myAdaptor.setOnCalenderItemClickListener(new OnCalenderItemClickListener() {
@Override
public void onItemClicked(MyDate myDate) {
myChosenDateNote = myDate;
//set noteFragment data
final Bundle bundle = new Bundle();
bundle.putString("title", myChosenDateNote.getDate());
bundle.putString("bodyTxt", myChosenDateNote.getDescription());
final NoteFragment newNoteFrag = new NoteFragment();
newNoteFrag.setArguments(bundle);
//change the fragment
/* fragPlace.setVisibility(View.VISIBLE);
allNoteListAndTitle.setVisibility(View.GONE);
addNoteButton.hide();
replaceFragment(newNoteFrag);*/
//toDo go to activity/fragment
}
@Override
public void onItemLongClicked(MyDate myDate) {
customToolbarOption.setVisibility(View.VISIBLE);
calenderToolbar.setVisibility(View.GONE);
myChosenDateNote = myDate;
}
});
//add listener to custom toolbar option and set being achieved or not to be saved in database
customToolbarOption.setCustomToolbarOptionListener(new CustomToolbarOptionListener() {
@Override
public void onStarClicked(ImageView yellowS, ImageView blackS) {
starClicked(yellowS, blackS);
}
@Override
public void onDeleteClicked(final ImageView imageView) {
deleteClicked(imageView);
}
@Override
public void onCloseClicked() {
closeClicked();
}
});
} }
@Override private void closeClicked() {
public void onClick(View view) { customToolbarOption.setVisibility(View.GONE);
if (view.getId() == addDateBtn.getId()) { calenderToolbar.setVisibility(View.VISIBLE);
addNewDateAndDescription(); }
}
private void deleteClicked(ImageView imageView) {
AlertDialog.Builder alert = new AlertDialog.Builder(MyCalenderActivity.this);
alert.setMessage("are you sure you wanna delete it ??? ");
alert.setPositiveButton("yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
noteDataBase.dateNoreDAO().deleteDateNote(entityDates.get(myDates.indexOf(myChosenDateNote)));
init();
}
});
alert.setNegativeButton("no", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.cancel();
}
});
alert.show();
calenderToolbar.setVisibility(View.VISIBLE);
}
private void starClicked(ImageView yellowS, ImageView blackS) {
if (yellowS.getVisibility() == View.VISIBLE) {
yellowS.setVisibility(View.GONE);
blackS.setVisibility(View.VISIBLE);
myChosenDateNote.setAchieved(false);
} else {
yellowS.setVisibility(View.VISIBLE);
blackS.setVisibility(View.GONE);
myChosenDateNote.setAchieved(true);
}
} }
private void addNewDateAndDescription() { private void addNewDateAndDescription() {
Intent intent = new Intent(MyCalenderActivity.this, DatePickerActivity.class); Intent intent = new Intent(MyCalenderActivity.this, DatePickerActivity.class);
startActivity(intent); startActivity(intent);
...@@ -83,7 +184,13 @@ public class MyCalenderActivity extends AppCompatActivity implements View.OnClic ...@@ -83,7 +184,13 @@ public class MyCalenderActivity extends AppCompatActivity implements View.OnClic
private void setAllNoteListAndTitles() { private void setAllNoteListAndTitles() {
myDates = new ArrayList<>(); myDates = new ArrayList<>();
//todo get data from database //get data from database to set in recyclerView
entityDates = noteDataBase.dateNoreDAO().getAllDateNotes();
myDates = new ArrayList<>();
for (DateEntity dateEntity : entityDates) {
MyDate myDate = new MyDate(dateEntity.getDate(), dateEntity.getDescription(), dateEntity.isAchieved());
myDates.add(myDate);
}
} }
} }
\ No newline at end of file
package com.example.mynotepad.MenuFeatures.Calender.MyCalenderDataBase;
public class DateEntity {
}
...@@ -50,7 +50,7 @@ public class MyCalenderAdaptor extends RecyclerView.Adapter<MyCalenderAdaptor.Ca ...@@ -50,7 +50,7 @@ public class MyCalenderAdaptor extends RecyclerView.Adapter<MyCalenderAdaptor.Ca
public CalenderViewHolder(@NonNull View itemView) { public CalenderViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
dates = itemView.findViewById(R.id.titleTv); dateTV = itemView.findViewById(R.id.titleTv);
descriptionTV = itemView.findViewById(R.id.descriptionTv); descriptionTV = itemView.findViewById(R.id.descriptionTv);
isAchieved = false; isAchieved = false;
itemView.setOnClickListener(this); itemView.setOnClickListener(this);
......
...@@ -12,17 +12,22 @@ import android.widget.Toast; ...@@ -12,17 +12,22 @@ import android.widget.Toast;
import com.alirezaafkar.sundatepicker.DatePicker; import com.alirezaafkar.sundatepicker.DatePicker;
import com.alirezaafkar.sundatepicker.interfaces.DateSetListener; import com.alirezaafkar.sundatepicker.interfaces.DateSetListener;
import com.example.mynotepad.MenuFeatures.AllNotes.AllNotesActivity;
import com.example.mynotepad.MenuFeatures.Calender.Date; import com.example.mynotepad.MenuFeatures.Calender.Date;
import com.example.mynotepad.MenuFeatures.AllNotes.NotesDataBase.DateEntity;
import com.example.mynotepad.R; import com.example.mynotepad.R;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import java.util.Calendar; import java.util.Calendar;
import static com.example.mynotepad.MainActivity.noteDataBase;
public class DatePickerActivity extends AppCompatActivity { public class DatePickerActivity extends AppCompatActivity {
TextView chosenDate, description; private DateEntity dateEntity;
Date mDate; private TextView chosenDate, description;
private Date mDate;
private FloatingActionButton back; private FloatingActionButton back;
@Override @Override
...@@ -71,7 +76,7 @@ public class DatePickerActivity extends AppCompatActivity { ...@@ -71,7 +76,7 @@ public class DatePickerActivity extends AppCompatActivity {
alert.setPositiveButton("yes", new DialogInterface.OnClickListener() { alert.setPositiveButton("yes", new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
saveNote(); saveDateNote();
Toast.makeText(DatePickerActivity.this, "saved", Toast.LENGTH_SHORT).show(); Toast.makeText(DatePickerActivity.this, "saved", Toast.LENGTH_SHORT).show();
finish(); finish();
} }
...@@ -95,7 +100,9 @@ public class DatePickerActivity extends AppCompatActivity { ...@@ -95,7 +100,9 @@ public class DatePickerActivity extends AppCompatActivity {
} }
} }
private void saveNote() { private void saveDateNote() {
//todo save in data base //todo save in data base
dateEntity = new DateEntity(chosenDate.getText().toString() , description.getText().toString() ,false);
noteDataBase.dateNoreDAO().insertDateNote(dateEntity);
} }
} }
\ No newline at end of file
...@@ -54,7 +54,7 @@ public class CustomToolbarOption extends LinearLayout implements View.OnClickLis ...@@ -54,7 +54,7 @@ public class CustomToolbarOption extends LinearLayout implements View.OnClickLis
public void onClick(View view) { public void onClick(View view) {
if (customToolbarOptionListener != null){ if (customToolbarOptionListener != null){
if (view.getId() == closeImg.getId()) if (view.getId() == closeImg.getId())
customToolbarOptionListener.onCloseClicked(closeImg); customToolbarOptionListener.onCloseClicked();
if (view.getId() == deleteImg.getId()) if (view.getId() == deleteImg.getId())
customToolbarOptionListener.onDeleteClicked(deleteImg); customToolbarOptionListener.onDeleteClicked(deleteImg);
if (view.getId() == yellowStarImg.getId() || view.getId() == blackStarImg.getId()) if (view.getId() == yellowStarImg.getId() || view.getId() == blackStarImg.getId())
......
...@@ -6,5 +6,5 @@ import android.widget.ImageView; ...@@ -6,5 +6,5 @@ import android.widget.ImageView;
public interface CustomToolbarOptionListener { public interface CustomToolbarOptionListener {
void onStarClicked(ImageView yellowS , ImageView blackS); void onStarClicked(ImageView yellowS , ImageView blackS);
void onDeleteClicked(ImageView imageView); void onDeleteClicked(ImageView imageView);
void onCloseClicked(ImageView imageView); void onCloseClicked();
} }
...@@ -16,18 +16,18 @@ ...@@ -16,18 +16,18 @@
app:srcCompat="@drawable/index" /> app:srcCompat="@drawable/index" />
<TextView <TextView
android:id="@+id/date1" android:id="@+id/date1"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/img" android:layout_below="@+id/img"
android:layout_marginStart="50dp" android:layout_marginStart="50dp"
android:layout_marginLeft="50dp" android:layout_marginLeft="50dp"
android:layout_marginTop="60dp" android:layout_marginTop="60dp"
android:enabled="false" android:background="@drawable/background"
android:text="@string/date" android:enabled="false"
android:textSize="30dp" android:text="@string/date"
android:textColor="#000000" android:textColor="#000000"
android:background="@drawable/background"/> android:textSize="30dp" />
<TextView <TextView
android:id="@+id/chosenDate" android:id="@+id/chosenDate"
...@@ -39,9 +39,9 @@ ...@@ -39,9 +39,9 @@
android:layout_toRightOf="@+id/date1" android:layout_toRightOf="@+id/date1"
android:background="@drawable/title_background" android:background="@drawable/title_background"
android:enabled="false" android:enabled="false"
android:textColor="#000000"
android:lines="1"
android:gravity="center" android:gravity="center"
android:lines="1"
android:textColor="#000000"
android:textSize="30dp" /> android:textSize="30dp" />
<TextView <TextView
...@@ -52,14 +52,13 @@ ...@@ -52,14 +52,13 @@
android:layout_marginStart="50dp" android:layout_marginStart="50dp"
android:layout_marginLeft="50dp" android:layout_marginLeft="50dp"
android:layout_marginTop="60dp" android:layout_marginTop="60dp"
android:background="@drawable/background"
android:enabled="false" android:enabled="false"
android:text="@string/description" android:text="@string/description"
android:textSize="30dp"
android:textColor="#000000" android:textColor="#000000"
android:background="@drawable/background"/> android:textSize="30dp" />
<TextView <LinearLayout
android:id="@+id/description"
android:layout_width="300dp" android:layout_width="300dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/date2" android:layout_below="@+id/date2"
...@@ -67,10 +66,17 @@ ...@@ -67,10 +66,17 @@
android:layout_marginLeft="50dp" android:layout_marginLeft="50dp"
android:layout_marginTop="21dp" android:layout_marginTop="21dp"
android:background="@drawable/title_background" android:background="@drawable/title_background"
android:lines="9" >
android:enabled="true"
android:textColor="#000000" <EditText
android:textSize="20dp" /> android:id="@+id/description"
android:layout_width="260dp"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:lines="9"
android:textColor="#000000" />
</LinearLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/calenderBackBtn" android:id="@+id/calenderBackBtn"
android:layout_width="wrap_content" android:layout_width="wrap_content"
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="3" android:layout_weight="3"
android:layout_marginLeft="15dp" android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:lines="3" android:lines="3"
android:text="body text" android:text="body text"
android:textSize="12dp" /> android:textSize="12dp" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment