List of usage examples for android.app ProgressDialog ProgressDialog
public ProgressDialog(Context context)
From source file:com.almarsoft.GroundhogReader.MessageListActivity.java
@Override protected Dialog onCreateDialog(int id) { ProgressDialog dialog = null;/*ww w. j ava2s . c om*/ if (id == ID_DIALOG_CATCHUP) { dialog = new ProgressDialog(this); dialog.setMessage(getString(R.string.catchingup_server)); dialog.setIndeterminate(true); dialog.setCancelable(false); return dialog; } return super.onCreateDialog(id); }
From source file:com.google.ytd.SubmitActivity.java
public void upload(Uri videoUri) { this.dialog = new ProgressDialog(this); dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setMessage("uploading ..."); dialog.setCancelable(false);/* w ww.j a v a2 s . c o m*/ dialog.show(); Handler handler = new Handler() { @Override public void handleMessage(Message msg) { dialog.dismiss(); String videoId = msg.getData().getString("videoId"); if (!Util.isNullOrEmpty(videoId)) { currentFileSize = 0; totalBytesUploaded = 0; Intent result = new Intent(); result.putExtra("videoId", videoId); setResult(RESULT_OK, result); finish(); } else { String error = msg.getData().getString("error"); if (!Util.isNullOrEmpty(error)) { Toast.makeText(SubmitActivity.this, error, Toast.LENGTH_LONG).show(); } } } }; asyncUpload(videoUri, handler); }
From source file:org.span.manager.MainActivity.java
@Override protected Dialog onCreateDialog(int id) { if (id == ID_DIALOG_STARTING) { progressDialog = new ProgressDialog(this); progressDialog.setTitle(getString(R.string.main_activity_start)); progressDialog.setMessage(getString(R.string.main_activity_start_summary)); progressDialog.setIndeterminate(false); progressDialog.setCancelable(true); return progressDialog; } else if (id == ID_DIALOG_STOPPING) { progressDialog = new ProgressDialog(this); progressDialog.setTitle(getString(R.string.main_activity_stop)); progressDialog.setMessage(getString(R.string.main_activity_stop_summary)); progressDialog.setIndeterminate(false); progressDialog.setCancelable(true); return progressDialog; } else if (id == ID_DIALOG_CONNECTING) { progressDialog = new ProgressDialog(this); progressDialog.setTitle(getString(R.string.main_activity_connect)); progressDialog.setMessage(getString(R.string.main_activity_connect_summary)); progressDialog.setIndeterminate(false); progressDialog.setCancelable(true); return progressDialog; }//ww w . jav a 2 s. c o m return null; }
From source file:net.networksaremadeofstring.rhybudd.ViewZenossDevice.java
/** Called when the activity is first created. */ @Override//from ww w . j av a 2 s .c om public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); settings = PreferenceManager.getDefaultSharedPreferences(this); setContentView(R.layout.view_zenoss_device3); actionbar = getActionBar(); actionbar.setDisplayHomeAsUpEnabled(true); actionbar.setHomeButtonEnabled(true); list = (ListView) findViewById(R.id.ZenossEventsList); errorHandler = new Handler() { public void handleMessage(Message msg) { try { Toast.makeText(ViewZenossDevice.this, msg.getData().getString("exception"), Toast.LENGTH_LONG) .show(); } catch (Exception e) { ////BugSenseHandler.sendException("ViewZenossDevice-ErrorHandler", e); } } }; loadAverageHandler = new Handler() { public void handleMessage(Message msg) { try { ((ImageView) findViewById(R.id.loadAverageGraph)).setImageDrawable(loadAverageGraph); } catch (Exception e) { e.printStackTrace(); } } }; CPUGraphHandler = new Handler() { public void handleMessage(Message msg) { try { ((ImageView) findViewById(R.id.CPUGraph)).setImageDrawable(CPUGraph); } catch (Exception e) { e.printStackTrace(); } } }; MemoryGraphHandler = new Handler() { public void handleMessage(Message msg) { try { ((ImageView) findViewById(R.id.MemoryGraph)).setImageDrawable(MemoryGraph); } catch (Exception e) { e.printStackTrace(); } } }; eventsHandler = new Handler() { public void handleMessage(Message msg) { try { //((ProgressBar) findViewById(R.id.eventsProgressBar)).setVisibility(4); } catch (Exception e) { ////BugSenseHandler.sendException("ViewZenossDevice", e); } if (EventCount > 0 && msg.what == 1) { try { adapter = new ZenossEventsAdaptor(ViewZenossDevice.this, listOfZenossEvents, false); list.setAdapter(adapter); } catch (Exception e) { ////BugSenseHandler.sendException("ViewZenossDevice", e); } } else { list = null; } } }; firstLoadHandler = new Handler() { public void handleMessage(Message msg) { if (dialog != null) dialog.dismiss(); try { if (DeviceObject != null && msg.what == 1 && DeviceObject.getJSONObject("result").getBoolean("success") == true) { //Log.i("DeviceDetails",DeviceObject.toString()); DeviceDetails = DeviceObject.getJSONObject("result").getJSONObject("data"); try { String Name = DeviceDetails.getString("snmpSysName").toUpperCase(); if (Name.equals("")) { Name = DeviceDetails.getString("name").toUpperCase(); } ((TextView) findViewById(R.id.deviceID)).setText(Name); //actionbar.setTitle(DeviceDetails.getString("snmpSysName")); actionbar.setSubtitle(Name); } catch (Exception e) { ((TextView) findViewById(R.id.deviceID)).setText("--"); } try { ((TextView) findViewById(R.id.modelTime)) .setText(DeviceDetails.getString("lastCollected")); } catch (Exception e) { ((TextView) findViewById(R.id.modelTime)).setText("Unknown"); } try { ((TextView) findViewById(R.id.firstSeen)).setText(DeviceDetails.getString("firstSeen")); } catch (Exception e) { ((TextView) findViewById(R.id.firstSeen)).setText(""); } try { ((TextView) findViewById(R.id.location)) .setText(DeviceDetails.getString("snmpLocation")); } catch (Exception e) { ((TextView) findViewById(R.id.location)).setText("Unknown Location"); } try { ((TextView) findViewById(R.id.uptime)).setText(DeviceDetails.getString("uptime")); } catch (Exception e) { //Already got a placeholder } try { ((TextView) findViewById(R.id.productionState)) .setText(DeviceDetails.getString("productionState")); } catch (Exception e) { //Already got a placeholder } try { ((TextView) findViewById(R.id.memorySwap)) .setText(DeviceDetails.getJSONObject("memory").getString("ram") + " / " + DeviceDetails.getJSONObject("memory").getString("swap")); } catch (Exception e) { //Already got a placeholder } String Groups = ""; try { for (int i = 0; i < DeviceDetails.getJSONArray("groups").length(); i++) { if (i > 0) Groups += ", "; try { Groups += DeviceDetails.getJSONArray("groups").getJSONObject(i) .getString("name"); } catch (Exception e) { ////BugSenseHandler.sendException("ViewZenossDevice", e); } } ((TextView) findViewById(R.id.groups)).setText(Groups); } catch (Exception e) { ////BugSenseHandler.sendException("ViewZenossDevice", e); } String Systems = ""; try { for (int i = 0; i < DeviceDetails.getJSONArray("systems").length(); i++) { if (i > 0) Systems += ", "; Systems += DeviceDetails.getJSONArray("systems").getJSONObject(i).getString("name"); } ((TextView) findViewById(R.id.systems)).setText(Systems); } catch (Exception e) { //Already got a placeholder ////BugSenseHandler.sendException("ViewZenossDevice", e); } //etc } else { Toast.makeText(ViewZenossDevice.this, "There was an error loading the Device details", Toast.LENGTH_LONG).show(); //finish(); } } catch (Exception e) { //e.printStackTrace(); Toast.makeText(ViewZenossDevice.this, "An error was encountered parsing the JSON.", Toast.LENGTH_LONG).show(); ////BugSenseHandler.sendException("ViewZenossDevice", e); } } }; dialog = new ProgressDialog(this); dialog.setTitle("Contacting Zenoss"); dialog.setMessage("Please wait:\nLoading Device details...."); dialog.show(); dataPreload = new Thread() { public void run() { try { Message msg = new Message(); Bundle bundle = new Bundle(); if (API == null) { try { /*if(settings.getBoolean("httpBasicAuth", false)) { API = new ZenossAPIv2(settings.getString("userName", ""), settings.getString("passWord", ""), settings.getString("URL", ""),settings.getString("BAUser", ""), settings.getString("BAPassword", "")); } else { API = new ZenossAPIv2(settings.getString("userName", ""), settings.getString("passWord", ""), settings.getString("URL", "")); }*/ } /*catch(ConnectTimeoutException cte) { if(cte.getMessage() != null) { //Toast.makeText(ViewZenossDevice.this, "An error was encountered;\r\n" + cte.getMessage().toString(), Toast.LENGTH_LONG).show(); bundle.putString("exception","The connection timed out;\r\n" + cte.getMessage().toString()); msg.setData(bundle); msg.what = 0; errorHandler.sendMessage(msg); } else { bundle.putString("exception","A time out error was encountered but the exception thrown contains no further information."); msg.setData(bundle); msg.what = 0; errorHandler.sendMessage(msg); //Toast.makeText(ViewZenossDevice.this, "An error was encountered but the exception thrown contains no further information.", Toast.LENGTH_LONG).show(); } }*/ catch (Exception e) { if (e.getMessage() != null) { bundle.putString("exception", "An error was encountered;\r\n" + e.getMessage().toString()); msg.setData(bundle); msg.what = 0; errorHandler.sendMessage(msg); //Toast.makeText(ViewZenossDevice.this, "An error was encountered;\r\n" + e.getMessage().toString(), Toast.LENGTH_LONG).show(); } else { bundle.putString("exception", "An error was encountered but the exception thrown contains no further information."); msg.setData(bundle); msg.what = 0; errorHandler.sendMessage(msg); //Toast.makeText(ViewZenossDevice.this, "An error was encountered but the exception thrown contains no further information.", Toast.LENGTH_LONG).show(); } } DeviceObject = API.GetDevice(getIntent().getStringExtra("UID")); } } catch (Exception e) { //e.printStackTrace(); //BugSenseHandler.sendException("updateDevices-dataPreload",e); firstLoadHandler.sendEmptyMessage(0); } firstLoadHandler.sendEmptyMessage(1); } }; dataPreload.start(); loadAvgGraphLoad = new Thread() { public void run() { try { if (API == null) { Message msg = new Message(); Bundle bundle = new Bundle(); try { /*if(settings.getBoolean("httpBasicAuth", false)) { API = new ZenossAPIv2(settings.getString("userName", ""), settings.getString("passWord", ""), settings.getString("URL", ""),settings.getString("BAUser", ""), settings.getString("BAPassword", "")); } else { API = new ZenossAPIv2(settings.getString("userName", ""), settings.getString("passWord", ""), settings.getString("URL", "")); }*/ if (PreferenceManager.getDefaultSharedPreferences(ViewZenossDevice.this) .getBoolean(ZenossAPI.PREFERENCE_IS_ZAAS, false)) { API = new ZenossAPIZaas(); } else { API = new ZenossAPICore(); } ZenossCredentials credentials = new ZenossCredentials(ViewZenossDevice.this); API.Login(credentials); } catch (Exception e) { e.printStackTrace(); } } JSONObject graphURLs = API.GetDeviceGraphs(getIntent().getStringExtra("UID")); //Log.e("graphURLs",graphURLs.toString(3)); int urlCount = graphURLs.getJSONObject("result").getJSONArray("data").length(); for (int i = 0; i < urlCount; i++) { JSONObject currentGraph = null; try { currentGraph = graphURLs.getJSONObject("result").getJSONArray("data").getJSONObject(i); if (currentGraph.getString("title").equals("Load Average")) { loadAverageGraph = API.GetGraph(currentGraph.getString("url")); loadAverageHandler.sendEmptyMessage(1); } else if (currentGraph.getString("title").equals("CPU Utilization")) { CPUGraph = API.GetGraph(currentGraph.getString("url")); CPUGraphHandler.sendEmptyMessage(1); } else if (currentGraph.getString("title").equals("Memory Utilization")) { MemoryGraph = API.GetGraph(currentGraph.getString("url")); MemoryGraphHandler.sendEmptyMessage(1); } } catch (Exception e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } } }; loadAvgGraphLoad.start(); eventsLoad = new Thread() { public void run() { try { if (API == null) { Message msg = new Message(); Bundle bundle = new Bundle(); try { /*if(settings.getBoolean("httpBasicAuth", false)) { API = new ZenossAPIv2(settings.getString("userName", ""), settings.getString("passWord", ""), settings.getString("URL", ""),settings.getString("BAUser", ""), settings.getString("BAPassword", "")); } else { API = new ZenossAPIv2(settings.getString("userName", ""), settings.getString("passWord", ""), settings.getString("URL", "")); }*/ if (PreferenceManager.getDefaultSharedPreferences(ViewZenossDevice.this) .getBoolean(ZenossAPI.PREFERENCE_IS_ZAAS, false)) { API = new ZenossAPIZaas(); } else { API = new ZenossAPICore(); } ZenossCredentials credentials = new ZenossCredentials(ViewZenossDevice.this); API.Login(credentials); } catch (ConnectTimeoutException cte) { if (cte.getMessage() != null) { //Toast.makeText(ViewZenossDevice.this, , Toast.LENGTH_LONG).show(); bundle.putString("exception", "An error was encountered;\r\n" + cte.getMessage().toString()); } else { //Toast.makeText(ViewZenossDevice.this, "An error was encountered but the exception thrown contains no further information.", Toast.LENGTH_LONG).show(); bundle.putString("exception", "An error was encountered but the exception thrown contains no further information."); } msg.setData(bundle); msg.what = 0; errorHandler.sendMessage(msg); } catch (Exception e) { if (e.getMessage() != null) { //Toast.makeText(ViewZenossDevice.this, "An error was encountered;\r\n" + e.getMessage().toString(), Toast.LENGTH_LONG).show(); bundle.putString("exception", "An error was encountered;\r\n" + e.getMessage().toString()); } else { //Toast.makeText(ViewZenossDevice.this, "An error was encountered but the exception thrown contains no further information.", Toast.LENGTH_LONG).show(); bundle.putString("exception", "An error was encountered but the exception thrown contains no further information."); } msg.setData(bundle); msg.what = 0; errorHandler.sendMessage(msg); } } /*try { EventsObject = API.GetDeviceEvents(getIntent().getStringExtra("UID"),false); } catch(Exception e) { e.printStackTrace(); }*/ /*try { if((EventsObject.has("type") && EventsObject.get("type").equals("exception")) || !EventsObject.getJSONObject("result").has("totalCount") ) { EventsObject = API.GetDeviceEvents(getIntent().getStringExtra("UID"),true); } } catch(Exception e) { e.printStackTrace(); }*/ if (null != EventsObject && EventsObject.has("result") && EventsObject.getJSONObject("result").getInt("totalCount") > 0) { Events = EventsObject.getJSONObject("result").getJSONArray("events"); try { if (EventsObject != null) { EventCount = EventsObject.getJSONObject("result").getInt("totalCount"); for (int i = 0; i < EventCount; i++) { //JSONObject CurrentEvent = null; try { //CurrentEvent = Events.getJSONObject(i); listOfZenossEvents.add(new ZenossEvent(Events.getJSONObject(i))); //Log.i("ForLoop",CurrentEvent.getString("summary")); } catch (JSONException e) { //Log.e("API - Stage 2 - Inner", e.getMessage()); } catch (Exception e) { //BugSenseHandler.sendException("ViewZenossDevice-EventsLoop", e); } } eventsHandler.sendEmptyMessage(1); } else { //Log.i("eventsLoad","Had a problem; EventsObject was null"); //eventsHandler.sendEmptyMessage(0); } } catch (JSONException e) { e.printStackTrace(); //BugSenseHandler.sendException("ViewZenossDevice-Events", e); eventsHandler.sendEmptyMessage(0); } } else { eventsHandler.sendEmptyMessage(0); } } catch (Exception e) { //Log.e("API - Stage 1", e.getMessage()); //BugSenseHandler.sendException("ViewZenossDevice-Events", e); eventsHandler.sendEmptyMessage(0); } } }; eventsLoad.start(); }
From source file:net.palacesoft.cngstation.client.StationActivity.java
public ProgressDialog createProgressDialog(String message) { ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.setMessage(message);/*from www. j a v a2 s . c o m*/ progressDialog.setCancelable(true); return progressDialog; }
From source file:org.liberty.android.fantastischmemopro.downloader.DownloaderAnyMemo.java
private void downloadDatabase(final DownloadItem di) throws Exception { String filename = di.getExtras("filename"); if (filename == null) { throw new Exception("Could not get filename"); }//from w w w. j a v a 2s . co m String sdpath = Environment.getExternalStorageDirectory().getAbsolutePath() + getString(R.string.default_dir); File outFile = new File(sdpath + filename); mHandler.post(new Runnable() { public void run() { mProgressDialog = new ProgressDialog(DownloaderAnyMemo.this); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mProgressDialog.setMessage(getString(R.string.loading_downloading)); mProgressDialog.show(); } }); try { OutputStream out; if (outFile.exists()) { throw new IOException("Database already exist!"); } try { outFile.createNewFile(); out = new FileOutputStream(outFile); URL myURL = new URL(di.getAddress()); Log.v(TAG, "URL IS: " + myURL); URLConnection ucon = myURL.openConnection(); final int fileSize = ucon.getContentLength(); mHandler.post(new Runnable() { public void run() { mProgressDialog.setMax(fileSize); } }); byte[] buf = new byte[8192]; InputStream is = ucon.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is, 8192); Runnable increaseProgress = new Runnable() { public void run() { mProgressDialog.setProgress(mDownloadProgress); } }; int len = 0; int lenSum = 0; while ((len = bis.read(buf)) != -1) { out.write(buf, 0, len); lenSum += len; if (lenSum > fileSize / 50) { /* This is tricky. * The UI thread can not be updated too often. * So we update it only 50 times */ mDownloadProgress += lenSum; lenSum = 0; mHandler.post(increaseProgress); } } out.close(); is.close(); /* Uncompress the zip file that contains images */ if (filename.endsWith(".zip")) { mHandler.post(new Runnable() { public void run() { mProgressDialog.setProgress(fileSize); mProgressDialog.setMessage(getString(R.string.downloader_extract_zip)); } }); BufferedOutputStream dest = null; BufferedInputStream ins = null; ZipEntry entry; ZipFile zipfile = new ZipFile(outFile); Enumeration<?> e = zipfile.entries(); while (e.hasMoreElements()) { entry = (ZipEntry) e.nextElement(); Log.v(TAG, "Extracting: " + entry); if (entry.isDirectory()) { new File(sdpath + "/" + entry.getName()).mkdir(); } else { ins = new BufferedInputStream(zipfile.getInputStream(entry), 8192); int count; byte data[] = new byte[8192]; FileOutputStream fos = new FileOutputStream(sdpath + "/" + entry.getName()); dest = new BufferedOutputStream(fos, 8192); while ((count = ins.read(data, 0, 8192)) != -1) { dest.write(data, 0, count); } dest.flush(); dest.close(); ins.close(); } } /* Delete the zip file if it is successfully decompressed */ outFile.delete(); } /* We do not check ttf file as db */ if (!filename.toLowerCase().endsWith(".ttf")) { /* Check if the db is correct */ filename = filename.replace(".zip", ".db"); DatabaseHelper dh = new DatabaseHelper(DownloaderAnyMemo.this, sdpath, filename); dh.close(); } } catch (Exception e) { if (outFile.exists()) { outFile.delete(); } throw new Exception(e); } } catch (Exception e) { Log.e(TAG, "Error downloading", e); throw new Exception(e); } finally { mHandler.post(new Runnable() { public void run() { mProgressDialog.dismiss(); } }); } }
From source file:com.trailbehind.android.iburn.map.MapActivity.java
protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ABOUT: final ScrollView dialogView = (ScrollView) LayoutInflater.from(getBaseContext()) .inflate(R.layout.about_dialog, null); final TextView aboutText = (TextView) dialogView.findViewById(R.id.message); aboutText.setText(Utils.getAboutText(getBaseContext())); final String title = getString(R.string.title_dialog_about) + " " + getString(R.string.app_name); return new AlertDialog.Builder(this).setView(dialogView).setIcon(R.drawable.icon).setTitle(title) .setPositiveButton(R.string.close, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); }//from w ww .j ava 2 s . co m }).create(); case DIALOG_NO_INTERNET_DOWNLOAD: return new AlertDialog.Builder(MapActivity.this).setTitle(R.string.title_dialog_error) .setMessage(R.string.error_no_internet_download) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { removeDialog(DIALOG_NO_INTERNET_DOWNLOAD); } }).create(); case DIALOG_SDCARD_NOT_AVAILABLE: return new AlertDialog.Builder(this).setIcon(R.drawable.ic_dialog_menu_generic) .setTitle(R.string.title_dialog_error).setMessage(R.string.error_sd_not_available) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { removeDialog(DIALOG_SDCARD_NOT_AVAILABLE); } }).create(); case DIALOG_DOWNLOAD_PROGRESS: mProgressDialog = new ProgressDialog(MapActivity.this); mProgressDialog.setTitle(R.string.title_dialog_download); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mProgressDialog.setButton(getText(android.R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { removeDialog(DIALOG_DOWNLOAD_PROGRESS); for (int i = 0, len = mMapDownloadThreads.length; i < len; i++) { MapDownloadThread t = mMapDownloadThreads[i]; if (t != null) { t.cancel(); } mMapDownloadThreads[i] = null; } mFileCacheWriter.stopRunning(); mFileCacheWriter = null; } }); return mProgressDialog; case DIALOG_DOWNLOAD_ERROR: return new AlertDialog.Builder(MapActivity.this).setIcon(R.drawable.ic_dialog_menu_generic) .setTitle(R.string.title_dialog_error).setMessage(mErrorMsgId) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { removeDialog(DIALOG_SDCARD_NOT_AVAILABLE); } }).create(); default: return null; } }
From source file:de.da_sense.moses.client.abstraction.HardwareAbstraction.java
/** * This method reads the sensor list stored for the device on the server *//*from ww w .j a v a 2s . c o m*/ public void getHardwareParameters() { // *** SENDING GET_HARDWARE_PARAMETERS REQUEST TO SERVER ***// if (MosesService.getInstance() != null) MosesService.getInstance().executeLoggedIn(HookTypesEnum.POST_LOGIN_SUCCESS, MessageTypesEnum.REQUEST_GET_HARDWARE_PARAMETERS, new Executable() { @Override public void execute() { gethwprogressdialog = new ProgressDialog(mContext); gethwprogressdialog.setTitle("Hardware Informations"); gethwprogressdialog.setMessage("Retrieving..."); gethwprogressdialog.show(); new RequestGetHardwareParameters(new ReqClassGetHWParams(), RequestLogin.getSessionID(), extractDeviceIdFromSharedPreferences()).send(); } }); }
From source file:com.odoo.addons.crm.models.CRMLead.java
public void convertToOpportunity(final ODataRow lead, final List<Integer> other_lead_ids, final OnOperationSuccessListener listener) { new AsyncTask<Void, Void, Void>() { private ProgressDialog dialog; @Override/*from w w w. j av a2 s . c o m*/ protected void onPreExecute() { super.onPreExecute(); dialog = new ProgressDialog(mContext); dialog.setTitle(R.string.title_please_wait); dialog.setMessage(OResource.string(mContext, R.string.title_working)); dialog.setCancelable(false); dialog.show(); } @Override protected Void doInBackground(Void... params) { try { odoo.Odoo odoo = getServerDataHelper().getOdoo(); // Creating wizard record JSONObject values = new JSONObject(); values.put("name", (other_lead_ids.size() > 0) ? "merge" : "convert"); Object partner_id = false; ODataRow partner = null; if (!lead.getString("partner_id").equals("false")) { ResPartner resPartner = new ResPartner(mContext, getUser()); partner = resPartner.browse(lead.getInt("partner_id")); partner_id = partner.getInt("id"); } values.put("action", (partner == null) ? "create" : "exist"); values.put("partner_id", partner_id); JSONObject context = new JSONObject(); context.put("stage_type", "lead"); context.put("active_id", lead.getInt("id")); other_lead_ids.add(lead.getInt("id")); context.put("active_ids", JSONUtils.<Integer>toArray(other_lead_ids)); context.put("active_model", "crm.lead"); odoo.updateContext(context); JSONObject result = odoo.createNew("crm.lead2opportunity.partner", values); int lead_to_opp_partner_id = result.getInt("result"); // Converting lead to opportunity OArguments arg = new OArguments(); arg.add(lead_to_opp_partner_id); arg.add(context); odoo.call_kw("crm.lead2opportunity.partner", "action_apply", arg.get()); OValues val = new OValues(); val.put("type", "opportunity"); for (int id : other_lead_ids) { update(selectRowId(id), val); } } catch (Exception e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); dialog.dismiss(); if (listener != null) { listener.OnSuccess(); } } @Override protected void onCancelled() { super.onCancelled(); dialog.dismiss(); if (listener != null) { listener.OnCancelled(); } } }.execute(); }