Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugs Fixed By Palash #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 21 additions & 11 deletions app/src/main/java/com/example/todoappjava/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.example.todoappjava.db.DatabaseHelper;
Expand All @@ -23,45 +24,55 @@ public class MainActivity extends AppCompatActivity implements TodoAdapter.OnIte

private final ArrayList<TodoData> todoList = new ArrayList<>();
private final TodoAdapter todoAdapter = new TodoAdapter(todoList, this);

private final DatabaseHelper myDB = new DatabaseHelper(this);

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

initViews();
rvTodos.setLayoutManager(new LinearLayoutManager(this));
rvTodos.setAdapter(todoAdapter);
loadTodos();

btnAddTodo.setOnClickListener(v -> addTodo());
}

private void addTodo() {
String text = etTodo.getText().toString();
boolean isSuccess = myDB.insertData(text);
if(isSuccess){
Toast.makeText(this, "Todo added successfully!", Toast.LENGTH_SHORT).show();
if(text.isEmpty())
{
// Bug 1 fixed
Toast.makeText(MainActivity.this, "Empty TODO can't be saved", Toast.LENGTH_SHORT).show();
}
else{
boolean isSuccess = myDB.insertData(text);
//App Not Crashing
Toast.makeText(MainActivity.this, "Todo added successfully!", Toast.LENGTH_SHORT).show();
loadTodos();
} else {
Toast.makeText(this, "Something went wrong!", Toast.LENGTH_SHORT).show();
//Solved bug 2
etTodo.setText("");
}
}

private TextView tt;
@SuppressLint("NotifyDataSetChanged")
private void loadTodos() {
Cursor cursor = myDB.getAllData();
if(cursor!=null){
tt=findViewById(R.id.textView);
if (cursor.moveToFirst()) {
tt.setText("");
String todoText;
int todoId;
// bug 3 Fixed
do {
todoId = cursor.getInt(cursor.getColumnIndex(DatabaseHelper.TODO_ID));
todoText = cursor.getString(cursor.getColumnIndex(DatabaseHelper.TODO_TEXT));
todoList.add(new TodoData(todoId, todoText));
} while (cursor.moveToNext());
todoList.add(new TodoData(todoId, todoText));
}
else{
// bug 7 fixed
tt.setText("TODO LIST Empty !! \n ADD A Task to see the LIST .");
}
cursor.close();
todoAdapter.notifyDataSetChanged();
Expand All @@ -73,7 +84,6 @@ private void initViews() {
etTodo = findViewById(R.id.etTodo);
btnAddTodo = findViewById(R.id.btnAddTodo);
}

@Override
public void onDeleteClick(int position) {
String itemIdToDelete = String.valueOf(todoList.get(position).getId());
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/example/todoappjava/TodoAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener

public ViewHolder(@NonNull View itemView) {
super(itemView);
tvTodoId=itemView.findViewById(R.id.tvTodoId);
tvTodoText = itemView.findViewById(R.id.tvTodoText);
btnDelete = itemView.findViewById(R.id.btnDelete);

Expand Down
23 changes: 18 additions & 5 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
Expand Down Expand Up @@ -30,17 +29,31 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginHorizontal="8dp"
android:inputType="textCapSentences"
android:layout_weight="2"
android:hint="Enter Todo Text" />
android:hint="@string/enter_todo_text"
android:inputType="textCapSentences"
tools:ignore="TextContrastCheck" />

<Button
android:id="@+id/btnAddTodo"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginHorizontal="8dp"
android:layout_weight="1"
android:text="Add" />
android:text="@string/add" />
</androidx.appcompat.widget.LinearLayoutCompat>

<TextView
android:id="@+id/textView"
android:layout_width="294dp"
android:layout_height="165dp"
android:gravity="center"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.433" />

</androidx.constraintlayout.widget.ConstraintLayout>
7 changes: 4 additions & 3 deletions app/src/main/res/layout/todo_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
android:layout_height="wrap_content"
android:gravity="center"
android:paddingHorizontal="14dp"
android:text="1"
android:text="@string/_1"
android:textSize="20sp" />

<TextView
Expand All @@ -25,7 +25,7 @@
android:layout_toStartOf="@+id/btnDelete"
android:layout_toEndOf="@+id/tvTodoId"
android:paddingEnd="6dp"
android:text="Some Todo Text"
android:text="@string/some_todo_text"
android:textColor="@color/black"
android:textSize="20sp"
tools:ignore="RtlSymmetry" />
Expand All @@ -43,6 +43,7 @@
android:layout_marginBottom="0dp"
android:background="?android:selectableItemBackground"
android:foregroundGravity="right"
android:src="@drawable/ic_delete" />
android:src="@drawable/ic_delete"
tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" />

</RelativeLayout>
5 changes: 0 additions & 5 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml

This file was deleted.

5 changes: 0 additions & 5 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml

This file was deleted.

Binary file added app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-hdpi/ic_launcher.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-mdpi/ic_launcher.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<resources>
<string name="app_name">Todo App Java</string>
<string name="_1">1</string>
<string name="some_todo_text">Some Todo Text</string>
<string name="add">Add</string>
<string name="enter_todo_text">Enter Todo Text</string>
</resources>