Skip to content

Conversation

@aneeshj4
Copy link
Contributor

Fix

String host = intent.getStringExtra(SocialsAdapter.HOST_KEY);
String description = intent.getStringExtra(SocialsAdapter.DESCRIPTION_KEY);
String image = intent.getStringExtra(SocialsAdapter.FIREBASE_URL);
final int numberInterested = intent.getIntExtra(SocialsAdapter.NUMBER_INTERESTED, -1);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is -1, I can't tell (is it the default value?). Specify in a final variable what this is. Maybe call it DEFAULT_INTERESTED so it's easier to read and easier to change later.

firebaseKey = intent.getStringExtra(SocialsAdapter.FIREBASE_KEY);

//Download image asynchronously
class DownloadFilesTask extends AsyncTask<String, Void, Bitmap> {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be defines outside the onCreate and wouldn't change anything except code readability



//Retrieving image from firebase storage
FirebaseStorage.getInstance().getReferenceFromUrl("gs://mdbsocials-fdfae.appspot.com").child(image + ".png").getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be final String

descriptionDetail.setText(getString(R.string.descriptionIntro) + description);

switch(numberInterested) {
case 1:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While switch cases are nice, there's really no point if you're doing a simple if else thing. Switch case is more for when you have 3 or more cases. Not really a problem, just don't feel pressured to always use a switch case


public static void addInterestedToDatabase(int interested, String firekey) {
DatabaseReference ref = FirebaseDatabase.getInstance().getReference("/socials");
ref.child(firekey).child("numberInterested").setValue(interested);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These types of strings are important to keep as final variables to ensure consistency. You can get a String wrong in another class, but you can't get a variable name wrong and still compile

//Connect people interested in social with recycler view layout
Log.d("InterestedActivity", "Int");
RecyclerView recyclerViewInterested = (RecyclerView) findViewById(R.id.recyclerInterested);
recyclerViewInterested.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the this keyword is alright, though you can use getApplicationContext() if you really want to be precise

*/

mAuthListener = new FirebaseAuth.AuthStateListener() {
@Override
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not add this to FirebaseUtils too?


@Override
public void onDestroy() {
super.onDestroy();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onDestroy also calls onStop, no need to repeat this code

.setPositiveButton("Camera", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, 1);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 should be a final variable called CAMERA_CODE or something

public static final String PEOPLE_INTERESTED = "peopleInterested";
public static final String NUMBER_INTERESTED = "numberInterested";
public static final String FIREBASE_URL = "firebaseURL";
public static final String FIREBASE_KEY = "firebaseKey";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you use these keys in other classes too, better to just put them in a Utils class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants