HiveBrain v1.2.0
Get Started
← Back to all entries
patternjavaMinor

Android App Simple calendar/scheduler

Submitted by: @import:stackexchange-codereview··
0
Viewed 0 times
schedulersimpleandroidappcalendar

Problem

Wanted to make a schedule for myself that was (hopefully) light-weight. Right now it just has the bare essential function of saving text for a certain day.

Looking for advice on literally anything that could improve the code ie. more efficient/better style/adhering to standards/etc.

Here is a link to the github repository for easier reading: https://github.com/kalenpw/Kalendar

And the three main classes:

MainActivity.java

```
/*
kalenpw
kalenpwilliams@gmail.com

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

For a copy of the GNU General Public License see
http://www.gnu.org/licenses/
*/

package com.example.kalenpw.kalendar;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.CalendarView;
import android.widget.EditText;
import java.util.ArrayList;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{
CalendarView _Calendar = null;
Button _ButtonSave = null;
EditText _EditText = null;

Day _SelectedDay = null;

ArrayList _Schedule = new ArrayList<>();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Load previous entries
FileHandler fh = new FileHandler();
_Schedule = fh.deserializeObject();

//Setup widgets f

Solution

Please have a look at Java naming convention.
"Except for variables, all instance, class, and class constants are in mixed case with a lowercase first letter. Internal words start with capital letters. Variable names should not start with underscore _ or dollar sign $ characters, even though both are allowed."

I also would reccomend not to do heavy operations in main thread, as for example, in your code in onCreate() method

_Schedule = fh.deserializeObject();


It may cause ANR - Application Not Responding

Code Snippets

_Schedule = fh.deserializeObject();

Context

StackExchange Code Review Q#156884, answer score: 2

Revisions (0)

No revisions yet.