-
-
Notifications
You must be signed in to change notification settings - Fork 162
Solution (#3131): Error: RedisException #3277
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
Open
TFGSUMIT
wants to merge
1
commit into
nextcloud:main
Choose a base branch
from
TFGSUMIT:fix/issue-3131
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
path/to/app/src/main/java/it/niedermann/owncloud/notes/exception/ExceptionHandler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import android.content.Context; | ||
| import it.niedermann.owncloud.notes.persistence.NotesDatabase; | ||
|
|
||
| public class ExceptionHandler { | ||
| public void handleException(Context context, Exception exception) { | ||
| if (exception instanceof RedisException) { | ||
| Log.e("ExceptionHandler", "RedisException occurred", exception); | ||
| // Prevent note content from being replaced with error message | ||
| String noteContent = "Note content not available"; | ||
| } else { | ||
| // Handle other exceptions | ||
| } | ||
| } | ||
| } | ||
42 changes: 42 additions & 0 deletions
42
path/to/app/src/main/java/it/niedermann/owncloud/notes/main/ItemAdapter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import android.view.LayoutInflater; | ||
| import android.view.View; | ||
| import android.view.ViewGroup; | ||
| import android.widget.TextView; | ||
| import androidx.recyclerview.widget.RecyclerView; | ||
| import it.niedermann.owncloud.notes.persistence.NotesDatabase; | ||
|
|
||
| public class ItemAdapter extends RecyclerView.Adapter<ItemAdapter.ViewHolder> { | ||
| private NotesDatabase database; | ||
|
|
||
| public ItemAdapter(Context context) { | ||
| database = NotesDatabase.getInstance(context); | ||
| } | ||
|
|
||
| @Override | ||
| public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
| View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_layout, parent, false); | ||
| return new ViewHolder(view); | ||
| } | ||
|
|
||
| @Override | ||
| public void onBindViewHolder(ViewHolder holder, int position) { | ||
| try { | ||
| // Load note content from database | ||
| String noteContent = database.getNoteContent(); | ||
| holder.textView.setText(noteContent); | ||
| } catch (RedisException e) { | ||
| Log.e("ItemAdapter", "RedisException occurred", e); | ||
| // Prevent note content from being replaced with error message | ||
| holder.textView.setText("Note content not available"); | ||
| } | ||
| } | ||
|
|
||
| public class ViewHolder extends RecyclerView.ViewHolder { | ||
| public TextView textView; | ||
|
|
||
| public ViewHolder(View itemView) { | ||
| super(itemView); | ||
| textView = itemView.findViewById(R.id.text_view); | ||
| } | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
path/to/app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import android.os.Bundle; | ||
| import android.util.Log; | ||
| import androidx.appcompat.app.AppCompatActivity; | ||
| import it.niedermann.owncloud.notes.persistence.NotesDatabase; | ||
|
|
||
| public class MainActivity extends AppCompatActivity { | ||
| private NotesDatabase database; | ||
|
|
||
| @Override | ||
| protected void onCreate(Bundle savedInstanceState) { | ||
| super.onCreate(savedInstanceState); | ||
| database = NotesDatabase.getInstance(this); | ||
|
|
||
| try { | ||
| // Load note content from database | ||
| String noteContent = database.getNoteContent(); | ||
| } catch (RedisException e) { | ||
| Log.e("MainActivity", "RedisException occurred", e); | ||
| // Prevent note content from being replaced with error message | ||
| String noteContent = "Note content not available"; | ||
| } | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
path/to/app/src/main/java/it/niedermann/owncloud/notes/persistence/Note.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import androidx.room.Entity; | ||
| import androidx.room.PrimaryKey; | ||
|
|
||
| @Entity | ||
| public class Note { | ||
| @PrimaryKey | ||
| public int id; | ||
| public String content; | ||
| } |
12 changes: 12 additions & 0 deletions
12
path/to/app/src/main/java/it/niedermann/owncloud/notes/persistence/NoteDao.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import androidx.room.Dao; | ||
| import androidx.room.Query; | ||
| import it.niedermann.owncloud.notes.persistence.Note; | ||
|
|
||
| @Dao | ||
| public interface NoteDao { | ||
| @Query("SELECT * FROM notes") | ||
| List<Note> getNotes(); | ||
|
|
||
| @Query("SELECT content FROM notes WHERE id = :id") | ||
| String getNoteContent(int id); | ||
| } |
20 changes: 20 additions & 0 deletions
20
path/to/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import android.content.Context; | ||
| import androidx.room.Database; | ||
| import androidx.room.Room; | ||
| import androidx.room.RoomDatabase; | ||
| import it.niedermann.owncloud.notes.persistence.NoteDao; | ||
|
|
||
| @Database(entities = {Note.class}, version = 1) | ||
| public abstract class NotesDatabase extends RoomDatabase { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why we are creating new database with v1? |
||
| public abstract NoteDao noteDao(); | ||
|
|
||
| private static NotesDatabase INSTANCE; | ||
|
|
||
| public static synchronized NotesDatabase getInstance(Context context) { | ||
| if (INSTANCE == null) { | ||
| INSTANCE = Room.databaseBuilder(context.getApplicationContext(), NotesDatabase.class, "notes_database") | ||
| .build(); | ||
| } | ||
| return INSTANCE; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use Kotlin for new classes.