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

Reduce some codacy issues (Hacktoberfest) #31

Merged
merged 2 commits into from
Oct 16, 2016
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,27 @@

public class AdminActivity extends AppCompatActivity {

String title, detail, image, date;
Calendar calendar = Calendar.getInstance();
Button sendPushButton;
EditText pushNotificationTitleEditText, pushNotificationDetailEditText, pushNotificationImageEditText;
private String title, detail, image, date;
private Calendar calendar = Calendar.getInstance();
public EditText pushNotificationTitleEditText, pushNotificationDetailEditText, pushNotificationImageEditText;
public static EditText pushNotificationDateEditText;
Functions functions = new Functions();
ProgressDialog progressDialog;
Toolbar toolbar;
Long timeSinceEpoch;
public Functions functions = new Functions();
private ProgressDialog progressDialog;
public Long timeSinceEpoch;
private CoordinatorLayout coordinatorLayout;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_admin);
toolbar = (Toolbar) findViewById(R.id.toolbar_admin);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_admin);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
coordinatorLayout=(CoordinatorLayout)findViewById(R.id.admin_coordinator_layout);
progressDialog = new ProgressDialog(AdminActivity.this);
progressDialog.setMessage("Please wait");
progressDialog.setCancelable(false);
sendPushButton = (Button) findViewById(R.id.sendPushButton);
Button sendPushButton = (Button) findViewById(R.id.sendPushButton);
pushNotificationTitleEditText = (EditText) findViewById(R.id.pushNotificationTitleEditText);
pushNotificationDetailEditText = (EditText) findViewById(R.id.pushNotificationDetailEditText);
pushNotificationImageEditText = (EditText) findViewById(R.id.pushNotificationImageEditText);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
* Date : 24/12/14
*/
public class DialogActivity extends AppCompatActivity {
Fragment fragment;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dialog);
int f = getIntent().getIntExtra("Fragment", 1);
Fragment fragment;
switch (f) {
case 0: {
fragment = new LoginFragment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,17 @@
* Last Modified: 06/12/15
*/
public class HomeActivity extends AppCompatActivity {
Toolbar mToolbar;
DrawerLayout mDrawerLayout;
ActionBarDrawerToggle mDrawerToggle;
ListView drawerListView;
RecyclerView notificationsRecyclerView;
ArrayList<Notifications> notificationsArrayList;
SwipeRefreshLayout notificationSwipeRefreshLayout;
ProgressBar notificationLoadingProgressBar;
Functions functions = new Functions();
Realm realm;
boolean flag = false;
String value;
private Toolbar mToolbar;
private DrawerLayout mDrawerLayout;
private ActionBarDrawerToggle mDrawerToggle;
private RecyclerView notificationsRecyclerView;
private ArrayList<Notifications> notificationsArrayList;
private SwipeRefreshLayout notificationSwipeRefreshLayout;
private ProgressBar notificationLoadingProgressBar;
private Functions functions = new Functions();
private Realm realm;
private boolean flag = false;
private String value;
private CoordinatorLayout coordinatorLayout;

@Override
Expand Down Expand Up @@ -105,7 +104,7 @@ protected void onCreate(Bundle savedInstanceState) {
String[] val = {"GitHub Organisation", "Facebook Page", "Facebook Group", "Twitter", "Website", "Core Committee", "Mailing List"};
notificationSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.notificationSwipeRefreshLayout);
notificationsRecyclerView = (RecyclerView) findViewById(R.id.notification_recycler_view);
drawerListView = (ListView) findViewById(R.id.drawer_list);
ListView drawerListView = (ListView) findViewById(R.id.drawer_list);
drawerListView.setAdapter(new ArrayAdapter<>(HomeActivity.this, R.layout.navigation_drawer_list_item, R.id.navigation_drawer_item, val));

notificationSwipeRefreshLayout.setColorSchemeResources(R.color.peterRiver, R.color.alizarin, R.color.sunFlower, R.color.emerald);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
* Date : 24/12/14
*/
public class AboutFragment extends Fragment {
Button githubButton, rnrButton, sugButton, okButton;
Functions functions = new Functions();
Activity activity;
private Button githubButton, rnrButton, sugButton, okButton;
private Functions functions = new Functions();
private Activity activity;
private CoordinatorLayout coordinatorLayout;

@Override
Expand All @@ -55,7 +55,7 @@ public void onClick(View v) {
if (functions.isConnected(view.getContext())) {
functions.browserIntent(getActivity(), URL_GITHUB);
} else {
Snackbar snackbar = Snackbar.make(coordinatorLayout, "No Internet Connection", android.support.design.widget.Snackbar.LENGTH_SHORT);
Snackbar snackbar = Snackbar.make(coordinatorLayout, "No Internet Connection", Snackbar.LENGTH_SHORT);
snackbar.show();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
* Date : 24/12/14
*/
public class LoginFragment extends Fragment {
Button loginButton, cancelButton;
EditText passwordEditText;
Functions functions = new Functions();
Activity activity;
private Button loginButton, cancelButton;
private EditText passwordEditText;
private Functions functions = new Functions();
private Activity activity;
private CoordinatorLayout coordinatorLayout;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/

public class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener {
Calendar calendar=Calendar.getInstance();
private Calendar calendar=Calendar.getInstance();
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current time as the default values for the picker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void hideKeyboard(Context context, View view) {
* Function to show notification
*/
public void showNotification(String title, String subtitle, int icon,
Intent resultIntent, Context context, NotificationManager mNotifyMgr) {
Intent resultIntent, Context context) {

Uri soundUri = RingtoneManager
.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Expand All @@ -55,7 +55,7 @@ public void showNotification(String title, String subtitle, int icon,
.setContentTitle(title).setContentText(subtitle)
.setSmallIcon(icon).setContentIntent(pendingResultIntent)
.setSound(soundUri).setAutoCancel(true).build();
mNotifyMgr = (NotificationManager) context
NotificationManager mNotifyMgr = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
mNotifyMgr.cancelAll();
mNotifyMgr.notify(0, mBuilder);
Expand All @@ -65,16 +65,15 @@ public void showNotification(String title, String subtitle, int icon,
* Fuction to show notification without sound
*/
public void showNotificationNoSound(String title, String subtitle,
int icon, Intent resultIntent, Context context,
NotificationManager mNotifyMgr) {
int icon, Intent resultIntent, Context context) {

PendingIntent pendingResultIntent = PendingIntent.getActivity(context,
0, resultIntent, PendingIntent.FLAG_CANCEL_CURRENT);
Notification mBuilder = new NotificationCompat.Builder(context)
.setContentTitle(title).setContentText(subtitle)
.setSmallIcon(icon).setContentIntent(pendingResultIntent)
.setAutoCancel(true).build();
mNotifyMgr = (NotificationManager) context
NotificationManager mNotifyMgr = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
mNotifyMgr.cancelAll();
mNotifyMgr.notify(0, mBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*/
public class NotificationAdapter extends RecyclerView.Adapter<ViewHolder> {

ArrayList<Notifications> notificationsArrayList;
Context context;
private ArrayList<Notifications> notificationsArrayList;
private Context context;

public NotificationAdapter(ArrayList<Notifications> notificationsArrayList, Context context) {

Expand All @@ -40,11 +40,11 @@ public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
public void onBindViewHolder(final ViewHolder mHolder, int position){

final Notifications notifications = notificationsArrayList.get(position);
mHolder.detailTextView.setText(notifications.getDetail());
mHolder.titleTextView.setText(notifications.getTitle());
mHolder.setDetailText(notifications.getDetail());
mHolder.setTitleText(notifications.getTitle());
Date eventDate = new Date(notifications.getDate());
mHolder.dateTextView.setText(new SimpleDateFormat("kk:mm dd/MM/yyyy", Locale.ENGLISH).format(eventDate));
mHolder.addToCalendarButton.setOnClickListener(new View.OnClickListener() {
mHolder.setDateText(new SimpleDateFormat("kk:mm dd/MM/yyyy", Locale.ENGLISH).format(eventDate));
mHolder.setCalendarOnClick(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_EDIT);
Expand All @@ -56,13 +56,13 @@ public void onClick(View v) {
context.startActivity(intent);
}
});
mHolder.cardView.setOnClickListener(new View.OnClickListener() {
mHolder.setCardOnClick(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(mHolder.linearLayout.getVisibility() == View.GONE)
mHolder.linearLayout.setVisibility(View.VISIBLE);
if(mHolder.getLayoutVisibility() == View.GONE)
mHolder.setLayoutVisibility(View.VISIBLE);
else
mHolder.linearLayout.setVisibility(View.GONE);
mHolder.setLayoutVisibility(View.GONE);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
public class Notifications extends RealmObject {

@PrimaryKey
String title;
String detail;
String image;
long date;
private String title;
private String detail;
private String image;
private long date;

public String getTitle() {
return title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public class PushBroadcastReceiver extends ParsePushBroadcastReceiver {

String value = null;
private String value = null;

@Override
public void onPushOpen(Context context, Intent intent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
*/
public class ViewHolder extends RecyclerView.ViewHolder{

TextView titleTextView, detailTextView, dateTextView;
ImageView imageView;
Button addToCalendarButton;
CardView cardView;
LinearLayout linearLayout;
private TextView titleTextView, detailTextView, dateTextView;
private ImageView imageView;
private Button addToCalendarButton;
private CardView cardView;
private LinearLayout linearLayout;

public ViewHolder(View itemView) {

Expand All @@ -32,4 +32,32 @@ public ViewHolder(View itemView) {
addToCalendarButton = (Button) itemView.findViewById(R.id.notificationAddToCalenderButton);
linearLayout = (LinearLayout) itemView.findViewById(R.id.linear_layout);
}

public void setTitleText(String text) {
titleTextView.setText(text);
}

public void setDetailText(String text) {
detailTextView.setText(text);
}

public void setDateText(String text) {
dateTextView.setText(text);
}

public void setCalendarOnClick(View.OnClickListener listener) {
addToCalendarButton.setOnClickListener(listener);
}

public void setCardOnClick(View.OnClickListener listener) {
cardView.setOnClickListener(listener);
}

public void setLayoutVisibility(int visibility) {
linearLayout.setVisibility(visibility);
}

public int getLayoutVisibility() {
return linearLayout.getVisibility();
}
}