Skip to content
This repository was archived by the owner on Dec 17, 2020. It is now read-only.

Commit bc3607e

Browse files
committed
Demo: Extracted strings to resource files and some other small changes.
1 parent 91c22e8 commit bc3607e

File tree

18 files changed

+36
-23
lines changed

18 files changed

+36
-23
lines changed

demo/src/main/java/org/neotech/app/retainabletasksdemo/Main.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.neotech.app.retainabletasksdemo;
22

3+
import android.content.Intent;
4+
import android.net.Uri;
35
import android.os.Bundle;
46
import android.support.design.widget.FloatingActionButton;
57
import android.support.design.widget.Snackbar;
@@ -29,7 +31,6 @@ protected void onCreate(Bundle savedInstanceState) {
2931
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
3032

3133
findViewById(R.id.fab).setOnClickListener(this);
32-
3334
findViewById(R.id.button_no_ui_task).setOnClickListener(this);
3435
findViewById(R.id.button_progress_task).setOnClickListener(this);
3536
}
@@ -45,10 +46,10 @@ protected void onStart() {
4546
public void onClick(View v) {
4647
final int id = v.getId();
4748
if(id == R.id.fab){
48-
//TODO info
49+
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/NeoTech-Software/Android-Retainable-Tasks")));
4950
} else if(id == R.id.button_progress_task) {
5051
if (getTaskHandler().isRunning(TASK_PROGRESS)) {
51-
Toast.makeText(this, "Task already running.", Toast.LENGTH_SHORT).show();
52+
Toast.makeText(this, R.string.toast_task_already_running, Toast.LENGTH_SHORT).show();
5253
}
5354
SimpleTask task = new SimpleTask(TASK_PROGRESS);
5455
getTaskHandler().execute(task, this);
@@ -72,13 +73,13 @@ public void onPreExecute(Task<?, ?> task) {
7273
@Override
7374
public void onPostExecute(Task<?, ?> task) {
7475
progressDialog.dismiss();
75-
Snackbar.make(findViewById(android.R.id.content), "'Progress task' finished.", Snackbar.LENGTH_LONG).show();
76+
Snackbar.make(findViewById(android.R.id.content), getString(R.string.toast_task_finished, getString(R.string.task_progress_dialog)), Snackbar.LENGTH_LONG).show();
7677
}
7778

7879
@Override
7980
public void onCanceled(Task<?, ?> task) {
8081
progressDialog.dismiss();
81-
Snackbar.make(findViewById(android.R.id.content), "'Progress task' canceled.", Snackbar.LENGTH_LONG).show();
82+
Snackbar.make(findViewById(android.R.id.content), getString(R.string.toast_task_canceled, getString(R.string.task_progress_dialog)), Snackbar.LENGTH_LONG).show();
8283
}
8384

8485
@Override

demo/src/main/java/org/neotech/app/retainabletasksdemo/ProgressDialog.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.neotech.app.retainabletasksdemo;
22

3+
import android.annotation.SuppressLint;
34
import android.app.Dialog;
45
import android.content.DialogInterface;
56
import android.os.Bundle;
@@ -45,13 +46,15 @@ public static ProgressDialog showIfNotShowing(FragmentManager fragmentManager, S
4546
public Dialog onCreateDialog(Bundle savedInstanceState) {
4647
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
4748
View view = LayoutInflater.from(builder.getContext()).inflate(R.layout.dialog_progress, null, false);
49+
4850
progressPercentage = (TextView) view.findViewById(R.id.progress_percentage);
4951
progressCount = (TextView) view.findViewById(R.id.progress_count);
5052
progressBar = (ProgressBar) view.findViewById(android.R.id.progress);
5153
progressBar.setMax(100);
5254
progressBar.setIndeterminate(false);
5355
builder.setView(view);
54-
builder.setPositiveButton("Cancel", this);
56+
builder.setTitle(R.string.dialog_progress_title);
57+
builder.setPositiveButton(R.string.action_cancel, this);
5558
setCancelable(false);
5659
return builder.create();
5760
}
@@ -70,6 +73,7 @@ public void onSaveInstanceState(Bundle outState) {
7073
outState.putInt("progress", progress);
7174
}
7275

76+
@SuppressLint("SetTextI18n")
7377
public void setProgress(int progress){
7478
if(getDialog() != null) {
7579
progressBar.setProgress(progress);
1.27 KB
Loading
-595 Bytes
Binary file not shown.
821 Bytes
Loading
-376 Bytes
Binary file not shown.
1.76 KB
Loading
-796 Bytes
Binary file not shown.
2.67 KB
Loading
Binary file not shown.

0 commit comments

Comments
 (0)