How to implement ProgresDialog [Android] - android

I am experiencing a problem I have following code:
public void onCreate(Bundle savedInstanceState) {
MyDialog = ProgressDialog.show(this, "Nalagam kanale" , "Prosimo počakaj ... ", true);
MyDialog.show();
... }
Which should actually start he dialog... But the problem is that dialog is shown when everything is loaded...
How can I do solve that?
Actual code
package com.TVSpored;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ListView;
public class Currently extends Activity{
static final int PROGRESS_DIALOG = 0;
private ArrayList<CurrentlyItem> currentItems;
private CurrentAdapter aa;
private ListView currentListView;
private JSONArray CurrentShows;
private Communicator CommunicatorEPG;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.layout_currently);
CommunicatorEPG = new Communicator();
currentItems = new ArrayList<CurrentlyItem>();
if(currentItems == null)
int resID = R.layout.current_item;
aa = new CurrentAdapter(this, resID, currentItems);
currentListView = (ListView)findViewById(R.id.currentListView);
try {
currentListView.setAdapter(aa);
} catch (Exception e) {
Log.d(" * Napaka", e.toString());
}
try {
populateCurrent();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void populateCurrent() throws JSONException
{
CurrentShows = CommunicatorEPG.getCurrentShows(0);
for (int i = 0; i < CurrentShows.length(); i++)
{
JSONObject jsonObject = CurrentShows.getJSONObject(i);
String start = jsonObject.getString("1");
Integer duration = jsonObject.getInt("2");
String title = jsonObject.getString("3");
String epg_channel = jsonObject.getString("4");
String channel_name = jsonObject.getString("5");
CurrentlyItem newItem = new CurrentlyItem(1, 2, 3, 4, 5);
currentItems.add(i, newItem);
}
}
}
This is actual code... I would like to do populateCurrent(); in AsyncTask and meanwhile I would like a loading screen to be shown... Have been trying for few hours now but no actual success... I have successfully shown loading screen and wen trough JSONArray, but couldn't update listview...
Thanks for support!

Expected behaviour...
Show a dialog is a typical task of UI thread, but until you complete the onCreate method, the UI thread s not free to execute the dialog creation...
Two solution: create a dialog in a separate thread or execute your long task in a separate thread.
Some highlights here:
http://developer.android.com/guide/topics/ui/dialogs.html

You could wait to set the content of the activity until the you're finished with the progress dialog.
Update:
This would run your command in async-task:
new AsyncTask<Void, Void, Void> {
protected Long doInBackground(Void... voids) {
populateCurrent();
}
}.execute()
However, then you probably have to make sure to update the list in the GUI thread again and in some way tell the adapter that the list have been updated (since you've given that list to the adapter):
runOnUiThread(new Runnable() {
public void run() {
currentItems.add(i, newItem);
aa.notifyDataSetChanged();
}
}
It is probably best to create a new list entirely and set the view to view that.

Related

How can I delete an item from an online database via android application?

I started to develop Android recently and I'm having difficulty in solving a thing probably much simpler than what I think.
I am creating a CRUD application that communicates with an online database, I can read and enter data, unfortunately I can't delete and modify the list once it is created.
To manage the data that use JSON and the row in the list that I add is made up of three fields: animal_id, animal_name, animal_type.
The activity data on which I read and on which I want to implement methods to modify and delete via listener is formed by the following code:
import java.sql.Array;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
public class ListAnimalActivity extends ListActivity {
ArrayList<HashMap<String,?>> animalList;
JSONParser jParser = new JSONParser();
JSONArray animals = null;
Button button_add;
private static String url_read = "http://example.com/list_animals.php";
private static String url_delete = "http://example.com/delete_animal.php";
private static final String TAG_SUCCESS = "success";
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
load_ListAnimalActivity();
}
public void onResume(){
super.onResume();
load_ListAnimalActivity();
}
private void load_ListAnimalActivity(){
setContentView(R.layout.activity_list_animal);
animalList = new ArrayList<HashMap<String,?>>();
new Read_Object().execute();
final ListView listView = (ListView)findViewById(android.R.id.list);
final ListAdapter adapter = new SimpleAdapter(
ListAnimalActivity.this, animalList,
R.layout.row_list, new String[] { "animal_id",
"animal_name","animal_type"},
new int[] { R.id.animal_id, R.id.animal_name,R.id.animal_type });
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
#Override
public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
AlertDialog.Builder adb = new AlertDialog.Builder(ListAnimalActivity.this);
adb.setTitle("Attenzione!");
adb.setMessage("Vuoi eliminare l\'elemento \"" + animalList.get(position)+ "\" ?");
final int posizione = position;
adb.setNegativeButton("Annulla",new AlertDialog.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {}
});
adb.setPositiveButton("Elimina", new AlertDialog.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
new Delete_Object().execute();
}
});
adb.show();
}
});
button_add = (Button)findViewById(R.id.button_add);
button_add.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
startActivity(new Intent(ListAnimalActivity.this,CRUDAnimalActivity.class));
}
});
}
class Read_Object extends AsyncTask<String, String, String> {
private ProgressDialog progressMessage = new ProgressDialog(ListAnimalActivity.this);
#Override
protected void onPreExecute() {
super.onPreExecute();
progressMessage.setMessage("Loading ...");
progressMessage.setIndeterminate(false);
progressMessage.setCancelable(false);
progressMessage.show();
}
protected String doInBackground(String... args) {
List params = new ArrayList();
JSONObject json = jParser.makeHttpRequest(url_read, "POST", params);
try{
Log.d("Animals: ", json.toString());
} catch (NullPointerException e){
e.printStackTrace();
}
try {
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
animals = json.getJSONArray("animals");
for (int i = 0; i < animals.length(); i++) {
JSONObject c = animals.getJSONObject(i);
String id = c.getString("animal_id");
String name = c.getString("animal_name");
String type = c.getString("animal_type");
HashMap map = new HashMap();
map.put("animal_id", id);
map.put("animal_name", name);
map.put("animal_type", type);
animalList.add(map);
}
}
} catch (JSONException e) {
e.printStackTrace();
} catch (NullPointerException e){
e.printStackTrace();
}
return null;
}
protected void onPostExecute(String file_url) {
progressMessage.dismiss();
runOnUiThread(new Runnable() {
public void run() {
ListAdapter adapter = new SimpleAdapter(
ListAnimalActivity.this, animalList,
R.layout.row_list, new String[] { "animal_id",
"animal_name","animal_type"},
new int[] { R.id.animal_id, R.id.animal_name,R.id.animal_type });
setListAdapter(adapter);
}
});
}
}
class Delete_Object extends AsyncTask<String, String, String>{
private ProgressDialog progressMessage = new ProgressDialog(ListAnimalActivity.this);
#Override
protected void onPreExecute() {
super.onPreExecute();
progressMessage.setMessage("Deleting ...");
progressMessage.setIndeterminate(false);
progressMessage.setCancelable(false);
progressMessage.show();
}
protected String doInBackground(String... args) {
/*
Code to delete
*/
return null;
}
protected void onPostExecute(String file_url){
}
}
}
When i click on a list Item, the listener show me the object in this format:
{animal_type=firstType, animal_name=firstName, animal_id=1}
So my question is:
How can I collect only animal_id from the array animalList > ?
Your animalList is an array list with HashMaps as its elements, so when you call animalList.get(position), it will return a HashMap. To retrieve an animal_id just use :
(animalList.get(position)).get(animal_id).toString();
you have to create a Modelclass/Pojo Class (Private variable and getters and setters) for Animals,
ArrayList<AnimalModel> animalsArrayList = new ArrayList<AnimalModel>();
add the Animals object/data to animalsArrayList and listview.setAdapter(animalsArrayList);
then
listView.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
Object object = speakerListView.getItemAtPosition(position);
AnimalModel animals_data = (AnimalModel) object;
id = animals_data.getAnimal_id()
// call delete Async with thid Id
}
});
You code looks pretty messy. If I were you I would create a Custom Adapter that extends the base adapter and takes as a parameter either a hashmap or a list that you pass in the constructor. There you can have different listeners. Also if you want to notify the activity you can have the "luxury" to pass an interface as a parameter and notify the activity when something changes.
Regarding the json part, I would create two new classes, one which is a Thread Manager that receives tasks and handles them further and another class where u make the http calls and the json parsing.
I have done a similar application that receives data from a nebula interface and displays them to the user.

Android - Dynamically Create Controls in AsyncTask onPostExecute

I'm working on getting a better handle on AsyncTask and am trying to create controls dynamically with asyncTask's onPostExecute().
The code I have below does work and it creates controls, but is there a way to loop this, but delay it so that variable I is incremented after the asynctask completes?
I've read through using the get() method, but I can't seem to make it work.
Can anyone advise how to either wait till a background task is complete or some other way to dynamically create controls based on a variable number?
package com.example.dynamicallycreatecontrols;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.Log;
import android.view.Menu;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;
public class MainActivity extends Activity {
Integer i = 0;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
while (i < 5) {
new createControl().execute(i);
i++;
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
//asynctask
public class createControl extends AsyncTask<Integer, Void, Button> {
Button btn = new Button(MainActivity.this);
LinearLayout ll = (LinearLayout) findViewById (R.id.llMain);
LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
protected void onPreExecute(Integer i) {
// nothing right now
}
#Override
protected Button doInBackground(Integer... arg0) {
// TODO Auto-generated method stub
// do the calculation
return null;
}
protected void onPostExecute(Button v) {
// build the controls here
btn.setText("Play" + i);
ll.addView(btn, lp);
SystemClock.sleep(1000);
}
}
}
I'm new to android development and java so i'm not sure if I'm just misunderstanding a concept of get() or if there is a better way to do this all together.
Thanks for any time allocated in assistance.
-nick
When doInBackground() done I move to onPostExecute(). I don't need any delays there. When I call task.execute(/**/) actually I invoke doInBackground() async task and I don't care when it finish but I know that I have callback onPostExecute() and I wait and update my main Thread from there.
To make it clearer lets say you have application where user wants to register to server and update GUI led to green color. User presses on button and calls method registerClient()
This method runs:
private void registerClient(){
...
dialog = ProgressDialog.show(LoginActivity.this, "", "Connecting. Please wait...", true);
HeavyTask task = new HeavyTask();
task.execute(user, password, domain);
}
So what we have in HeavyTask:
private class HeavyTask extends AsyncTask<String, Void, Void> {
private String username = "";
private String domain = "";
private String password = "";
// run async task
protected Void doInBackground(String... args) {
username = args[0];
password = args[1];
domain = args[2];
registerClientToServer(username, password, domain, null);
return null;
}
protected void onPostExecute(Void results) {
mHandler.postDelayed(new Runnable() {
#Override
public void run() {
updateGUI(username, domain);
}
}, 500);
}
}
Why not create an object and instantiate it? You can control if the object exists or if it already finished what he had to do.
Example:
public class MainActivity extends Activity {
private createControl cc = null;
Integer i = 0;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
while (i < 5) {
if (cc == null){
cc = new createControl();
cc.execute(i);
i++;
}
}
}
...
}
Then in onPostExecute just add cc = null;

HTMLcleaner in AsyncTask

I am trying to get HTML cleaner to parse the info from a website and then use Xpath to find the data I'm looking for. I have the htmlcleaner stuff in a separate AsyncTask class and the app seems to work on my phone. However, when I push the button nothing happens. Here is my main activity class and my AsyncTask Class.
package ru.habrahabr.stackparser;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.htmlcleaner.TagNode;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;
public class stackParser extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.parse);
button.setOnClickListener(myListener);
}
private OnClickListener myListener = new OnClickListener() {
public void onClick(View v) {
new parseSite().execute("http://xjaphx.wordpress.com/");
}
};
private class parseSite extends AsyncTask<String, Void, String> {
protected String doInBackground(String... arg) {
String output = new String();
try {
htmlHelper hh = new htmlHelper();
} finally {
}
return output;
}
protected void onPostExecute(String output) {
TextView view = (TextView) findViewById(R.id.tv1);
view.setText((CharSequence) output);
}
}
}
And here's my referenced class. I'd really appreciate it if someone could look at this and tell me what's up. I tried to follow a working example and put my own Url and Xpath in but it's not working.
package ru.habrahabr.stackparser;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.htmlcleaner.HtmlCleaner;
import org.htmlcleaner.TagNode;
import org.htmlcleaner.XPatherException;
public class htmlHelper {
TagNode rootNode;
String stats;
static final String XPATH_STATS = "//div[#id='blog-stats']/ul/li";
public String htmlHelper(URL htmlPage) throws IOException, XPatherException {
HtmlCleaner cleaner = new HtmlCleaner();
rootNode = cleaner.clean(htmlPage);
// query XPath
Object[] statsNode = rootNode.evaluateXPath(XPATH_STATS);
// process data if found any node
if (statsNode.length > 0) {
TagNode resultNode = (TagNode) statsNode[0];
stats = resultNode.getText().toString();
}
return stats;
}
}
Change AsyncTask doInBackground method as :
#Override
protected String doInBackground(String... arg) {
String output "";
try {
htmlHelper hh = new htmlHelper();
output=hh.htmlHelper(arg[0]); //<< call htmlHelper method here
} finally {
}
return output;
}
because you are currently only creating an instance of htmlHelper class not calling htmlHelper method from htmlHelper class to get data from web url
Look , I will not care of the data is downloaded or not , but I will assume that the data is already downloaded and besides in the variable output , you just need to place this code inside onPostExecute
runOnUiThread(new Runnable() {
public void run() {
// update data into TextView.
TextView view = (TextView) findViewById(R.id.tv1);
view.setText((CharSequence) output);
}
});
because , sometimes the data is already downloaded but needed to be assigned into Textview or whatever view by using UIthread. Hope this works for you

Autocomplete address on android using geocoder

In my effort to get a simple address auto complete on android using geocoder, I tried to my patience and finally decided to ask out for help.
original code reference : Geocoder autocomplete in android
So in the below code, all that is happening is trying to auto complete the address as the user types in the autoCompleteTextView. I am calling the function doing the actual work in runOnUiThread,hoping that the UI would not freeze, as the user types in. However the UI freezes after the Threshold (3 characters) and the drop down of the possible addresses appear at it its own pace and not always.
If you guys can tell me where I am going wrong.... thanks in advance
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
public class AlarmActivity extends Activity implements TextWatcher {
private static final int THRESHOLD = 3;
private String latitude, longitude;
private List<Address> autoCompleteSuggestionAddresses;
private ArrayAdapter<String> autoCompleteAdapter;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.hw);
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
autoCompleteAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, new ArrayList<String>());
autoCompleteAdapter.setNotifyOnChange(false);
AutoCompleteTextView locationinput = (AutoCompleteTextView) findViewById(R.id.locationInput);
locationinput.addTextChangedListener(this);
locationinput.setOnItemSelectedListener(this);
locationinput.setThreshold(THRESHOLD);
locationinput.setAdapter(autoCompleteAdapter);
}
#Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
}
#Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
final String value = arg0.toString();
if (!"".equals(value) && value.length() >= THRESHOLD) {
Thread t = new Thread() {
public void run() {
try {
runOnUiThread(new Runnable() {
public void run() {
notifyResult(value);
}
});
} catch (Exception e) {}
}
};
t.start();
} else {
autoCompleteAdapter.clear();
}
}
#Override
public void afterTextChanged(Editable arg0) {
}
private void notifyResult(String value) {
try {
autoCompleteSuggestionAddresses = new Geocoder(getBaseContext()).getFromLocationName(value, 10);
//notifyResult(autoCompleteSuggestionAddresses);
latitude = longitude = null;
autoCompleteAdapter.clear();
for (Address a : autoCompleteSuggestionAddresses) {
Log.v("Nohsib", a.toString());
String temp = ""+ a.getFeatureName()+" "+a.getCountryName()+" "+a.getPostalCode();
autoCompleteAdapter.add(temp);
}
autoCompleteAdapter.notifyDataSetChanged();
} catch (IOException ex) {
// Log.e(GeoCoderAsyncTask.class.getName(), "Failed to get autocomplete suggestions", ex);
}
}
}
I believe the reason the UI is freezing is because even though you are calling notifyResult from a separate thread, it is still being run on the UI thread. What will fix this is to instead use an AsyncTask
Something like:
private class GetSuggestions extends AsyncTask<String, Void, Void> {
protected Long doInBackground(String... search) {
value = search[0];
try {
autoCompleteSuggestionAddresses = new Geocoder(getBaseContext()).getFromLocationName(value, 10);
//notifyResult(autoCompleteSuggestionAddresses);
latitude = longitude = null;
autoCompleteAdapter.clear();
for (Address a : autoCompleteSuggestionAddresses) {
Log.v("Nohsib", a.toString());
String temp = ""+ a.getFeatureName()+" "+a.getCountryName()+" "+a.getPostalCode();
autoCompleteAdapter.add(temp);
}
} catch (IOException ex) {
// Log.e(GeoCoderAsyncTask.class.getName(), "Failed to get autocomplete suggestions", ex);
}
}
protected void onPostExecute(Long result) {
autoCompleteAdapter.notifyDataSetChanged();
}
}
and then you can start the task by calling new GetSuggestions().execute(value);

Changing Text Alignment in ProgressDialog

I have problem that how to change text inside the progressdialog (basically having STYLE_HORIZONTAL as in figure) (Using Android 1.6)
to text shown in figure.
Please help out in this case.
My code about the progressdialog refers like this:-
mProgressDialog = new ProgressDialog(PDFActivity.this);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.setTitle(R.string.msgDownloadingWait);
mProgressDialog.setMessage(getResources().getString(
R.string.msgDownloading));
// User is not allowed to cancel the download operation.
mProgressDialog.setCancelable(false);
mProgressDialog.setMax(serverFileCount);
mProgressDialog.show();
Thanks in advance.
I got the answer related to this stuff some days back(but updating it today as got some free time).
Here the code that I have used for making this stuff best.I achieved above thing by Custom Dialog.Firstly here the code of activity from which I called the class of Custom Dialog.
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.widget.ProgressBar;
import android.widget.TextView;
public class ProgressThread extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MyDialog dialog = new MyDialog(this);
dialog.show();
}
}
Now the code related to the Custom Dialog. Here I have used ProgressBar & TextViews in CustomDialog & made calculations on basis on download which in turn updates TextViews.The example used here updates the textviews & progressbar in dummy manner.You change that as per your need.
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.os.Handler;
import android.os.Message;
import android.widget.ProgressBar;
import android.widget.TextView;
public class MyDialog extends Dialog {
public static final int STATUS_UPDATE = 101;
public static final int STATUS_COMPLETE = 100;
ProgressBar progressBar;
TextView textView;
TextView percent;
int increment;
int progress;
public MyDialog(Context context) {
super(context);
setContentView(R.layout.progressbar);
setDialog();
}
private void setDialog() {
setTitle("Downloading Files....");
textView = (TextView) findViewById(R.id.textProgress);
progressBar = (ProgressBar) findViewById(R.id.progress_horizontal);
percent = (TextView) findViewById(R.id.textPercentage);
percent.setTextColor(Color.WHITE);
textView.setTextColor(Color.WHITE);
progressBar.setProgressDrawable(getContext().getResources()
.getDrawable(R.drawable.my_progress));
progressBar.setIndeterminate(false);
// set the maximum value
progressBar.setMax(1315);
launcherThread();
}
private void launcherThread() {
LoaderThread loaderThread = new LoaderThread();
loaderThread.start();
LauncherThread launcherThread = new LauncherThread();
launcherThread.start();
}
private class LoaderThread extends Thread {
#Override
public void run() {
try {
while (progressBar.getProgress() < progressBar.getMax()) {
// wait 500ms between each update
Thread.sleep(100);
increment++;
// active the update handler
progressHandler.sendEmptyMessage(STATUS_UPDATE);
}
progressHandler.sendEmptyMessage(STATUS_COMPLETE);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
// handler for the background updating
Handler progressHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case STATUS_UPDATE:
progressBar.setProgress(increment);
float value = increment / 1315F;
percent.setText(" " + ((int) (value * 100)) + "%");
System.out.println(value * 100);
textView.setText(String.valueOf(progressBar.getProgress())
.concat(" / " + progressBar.getMax()));
break;
case STATUS_COMPLETE:
dismiss();
}
}
};
private class LauncherThread extends Thread {
#Override
public void run() {
progressHandler.sendMessage(progressHandler.obtainMessage());
progressHandler.sendEmptyMessage(0);
}
}
}

Categories

Resources