Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

fix: Toast Duration #89

Merged
merged 2 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -43,13 +43,13 @@ public void radioGroupOnCheckedChanged(RadioGroup group, int checkedId) {
case R.id.radio_donate:
binding.totalView.setVisibility(View.VISIBLE);
flag = 0;
Toast.makeText(getBaseContext(), getString(R.string.delete_donated), Toast.LENGTH_LONG)
Toast.makeText(getBaseContext(), getString(R.string.delete_donated), Toast.LENGTH_SHORT)
.show();
break;
case R.id.radio_pooja:
binding.totalView.setVisibility(View.VISIBLE);
flag = 1;
Toast.makeText(getBaseContext(), getString(R.string.delete_pooja), Toast.LENGTH_LONG)
Toast.makeText(getBaseContext(), getString(R.string.delete_pooja), Toast.LENGTH_SHORT)
Copy link
Member

Choose a reason for hiding this comment

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

Change to getBaseContext instead of getApplicationContext as this is that preferred way since this Context lives untill Application shuts down.
I am seeing so many unused changes please change that

Copy link
Contributor Author

@AnoopkRajan AnoopkRajan Jul 19, 2019

Choose a reason for hiding this comment

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

@Chromicle
Thanks for the review.
Can you please highlight the unused changes .
So that i can know the specifics.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should i also change to getBaseContext instead of getApplicationContext in MainActivity ?

.show();
break;
}
Expand Down Expand Up @@ -93,7 +93,7 @@ protected Void doInBackground(Void... params) {
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
dialog.dismiss();
Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG).show();
Toast.makeText(getBaseContext(), result, Toast.LENGTH_SHORT).show();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void onCheckedChanged(RadioGroup group, int checkedId) {
insertDataBinding.amount.setVisibility(View.GONE);
id = getResources().getString(R.string.DON);
flag = 0;
Toast.makeText(getBaseContext(), getString(R.string.selected_donate), Toast.LENGTH_LONG)
Toast.makeText(getBaseContext(), getString(R.string.selected_donate), Toast.LENGTH_SHORT)
.show();
break;

Expand All @@ -93,7 +93,8 @@ public void onCheckedChanged(RadioGroup group, int checkedId) {
insertDataBinding.spinner1.setVisibility(View.VISIBLE);
id = getString(R.string.REG);
flag = 1;
Toast.makeText(getBaseContext(), getString(R.string.selected_register), Toast.LENGTH_LONG)
Toast.makeText(
getBaseContext(), getString(R.string.selected_register), Toast.LENGTH_SHORT)
.show();
break;
}
Expand Down Expand Up @@ -161,7 +162,7 @@ protected Void doInBackground(Void... params) {
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
dialog.dismiss();
Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG).show();
Toast.makeText(getBaseContext(), result, Toast.LENGTH_SHORT).show();
}
}
}
20 changes: 10 additions & 10 deletions app/src/main/java/org/amfoss/templeapp/activities/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,44 +49,44 @@ public void onClick(DialogInterface dialog, int id) {

public class Presenter {
public void onInsertClick(View view) {
if (InternetConnection.checkConnection(getApplicationContext())) {
Intent intent = new Intent(getApplicationContext(), InsertData.class);
if (InternetConnection.checkConnection(getBaseContext())) {
Intent intent = new Intent(getBaseContext(), InsertData.class);
startActivity(intent);
} else {
createNetErrorDialog();
}
}

public void onReadAllClick(View view) {
if (InternetConnection.checkConnection(getApplicationContext())) {
Intent intent = new Intent(getApplicationContext(), ReadAllData.class);
if (InternetConnection.checkConnection(getBaseContext())) {
Intent intent = new Intent(getBaseContext(), ReadAllData.class);
startActivity(intent);
} else {
createNetErrorDialog();
}
}

public void onUpdateClick(View view) {
if (InternetConnection.checkConnection(getApplicationContext())) {
Intent intent = new Intent(getApplicationContext(), UpdateData.class);
if (InternetConnection.checkConnection(getBaseContext())) {
Intent intent = new Intent(getBaseContext(), UpdateData.class);
startActivity(intent);
} else {
createNetErrorDialog();
}
}

public void onReadSingleData(View view) {
if (InternetConnection.checkConnection(getApplicationContext())) {
Intent intent = new Intent(getApplicationContext(), ReadSingleData.class);
if (InternetConnection.checkConnection(getBaseContext())) {
Intent intent = new Intent(getBaseContext(), ReadSingleData.class);
startActivity(intent);
} else {
createNetErrorDialog();
}
}

public void onDeleteClick(View view) {
if (InternetConnection.checkConnection(getApplicationContext())) {
Intent intent = new Intent(getApplicationContext(), DeleteData.class);
if (InternetConnection.checkConnection(getBaseContext())) {
Intent intent = new Intent(getBaseContext(), DeleteData.class);
startActivity(intent);
} else {
createNetErrorDialog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ public void readAllButton(View view) {
|| readAllBinding.poojaNotPaid.isChecked()
|| readAllBinding.donatePaid.isChecked()
|| readAllBinding.donateNotPaid.isChecked())) {
Toast.makeText(
getApplicationContext(), getString(R.string.error_notSelected), Toast.LENGTH_LONG)
Toast.makeText(getBaseContext(), getString(R.string.error_notSelected), Toast.LENGTH_SHORT)
.show();
} else {
new ReadData1().execute();
Expand Down Expand Up @@ -220,8 +219,7 @@ protected void onPostExecute(Void aVoid) {
readAllBinding.heading.setVisibility(TextView.VISIBLE);

} else {
Toast.makeText(getApplicationContext(), getString(R.string.no_data), Toast.LENGTH_LONG)
.show();
Toast.makeText(getBaseContext(), getString(R.string.no_data), Toast.LENGTH_SHORT).show();
readAllBinding.heading.setVisibility(TextView.INVISIBLE);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ public void radioGroup(RadioGroup group, int checkedId) {
case R.id.radio_donate:
binding.totalView.setVisibility(View.VISIBLE);
flag = 0;
Toast.makeText(getBaseContext(), getString(R.string.selected_donate), Toast.LENGTH_LONG)
Toast.makeText(getBaseContext(), getString(R.string.selected_donate), Toast.LENGTH_SHORT)
.show();
break;
case R.id.radio_pooja:
binding.totalView.setVisibility(View.VISIBLE);
flag = 1;
Toast.makeText(getBaseContext(), getString(R.string.selected_register), Toast.LENGTH_LONG)
Toast.makeText(
getBaseContext(), getString(R.string.selected_register), Toast.LENGTH_SHORT)
.show();
break;
}
Expand Down Expand Up @@ -134,7 +135,7 @@ protected void onPostExecute(Void aVoid) {
binding.paidL.setText(getString(R.string.paid_status));

} else
Toast.makeText(getApplicationContext(), getString(R.string.id_not_found), Toast.LENGTH_LONG)
Toast.makeText(getBaseContext(), getString(R.string.id_not_found), Toast.LENGTH_SHORT)
.show();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void onCheckedChanged(RadioGroup group, int checkedId) {
binding.moneyDonated.setVisibility(View.VISIBLE);
id = getString(R.string.DON);
flag = 0;
Toast.makeText(getBaseContext(), getString(R.string.UPDATE), Toast.LENGTH_LONG).show();
Toast.makeText(getBaseContext(), getString(R.string.UPDATE), Toast.LENGTH_SHORT).show();
break;
case R.id.radio_pooja:
binding.totalView.setVisibility(View.VISIBLE);
Expand All @@ -92,7 +92,7 @@ public void onCheckedChanged(RadioGroup group, int checkedId) {
binding.amount.setVisibility(View.VISIBLE);
id = getString(R.string.REG);
flag = 1;
Toast.makeText(getBaseContext(), getString(R.string.update_pooja), Toast.LENGTH_LONG)
Toast.makeText(getBaseContext(), getString(R.string.update_pooja), Toast.LENGTH_SHORT)
.show();
break;
}
Expand Down Expand Up @@ -152,7 +152,7 @@ protected Void doInBackground(Void... params) {
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
dialog.dismiss();
Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG).show();
Toast.makeText(getBaseContext(), result, Toast.LENGTH_SHORT).show();
}
}
}