Skip to content

Commit

Permalink
Merge pull request #19 from faiyaz103/faiyaz
Browse files Browse the repository at this point in the history
App Crash Issue Solved
  • Loading branch information
faiyaz103 authored May 28, 2024
2 parents e0151b2 + 4f9bcef commit 47ccfdc
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
3 changes: 0 additions & 3 deletions .idea/deploymentTargetSelector.xml

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

1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<activity
android:name=".editnoteactivity"
android:exported="false"
android:parentActivityName=".notesActivity"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"/>
<activity
android:name=".createnote"
Expand Down
21 changes: 21 additions & 0 deletions app/src/main/java/com/example/notemania/MyLayoutManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.notemania;

import android.content.Context;
import android.util.AttributeSet;

import androidx.recyclerview.widget.StaggeredGridLayoutManager;

public class MyLayoutManager extends StaggeredGridLayoutManager {
public MyLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}

public MyLayoutManager(int spanCount, int orientation) {
super(spanCount, orientation);
}

@Override
public boolean supportsPredictiveItemAnimations() {
return false;
}
}
10 changes: 10 additions & 0 deletions app/src/main/java/com/example/notemania/editnoteactivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
Expand Down Expand Up @@ -95,4 +96,13 @@ public void onFailure(@NonNull Exception e) {
meditcontentofnote.setText(notecontent);
medittitleofnote.setText(notetitle);
}

@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if(item.getItemId() == android.R.id.home){
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}
8 changes: 5 additions & 3 deletions app/src/main/java/com/example/notemania/notesActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,10 @@ public NoteViewHolder onCreateViewHolder(@NonNull ViewGroup parent,int viewType)


mrecyleview=findViewById(R.id.recyclerview);
mrecyleview.setHasFixedSize(true);
staggeredGridLayoutManager=new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL);
mrecyleview.setLayoutManager(staggeredGridLayoutManager);
//mrecyleview.setHasFixedSize(true);
MyLayoutManager layoutManager = new MyLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
// staggeredGridLayoutManager=new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL);
mrecyleview.setLayoutManager(layoutManager);
mrecyleview.setAdapter(noteAdapter);


Expand Down Expand Up @@ -192,6 +193,7 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
@Override
protected void onStart() {
super.onStart();

noteAdapter.startListening();
}

Expand Down

0 comments on commit 47ccfdc

Please sign in to comment.