List of usage examples for android.os AsyncTask THREAD_POOL_EXECUTOR
Executor THREAD_POOL_EXECUTOR
To view the source code for android.os AsyncTask THREAD_POOL_EXECUTOR.
Click Source Link
From source file:com.aegiswallet.actions.MainActivity.java
@Override public void onPasswordProvided(String password, int action) { if (action == Constants.ACTION_ENCRYPT) { encryptWallet(password);// w w w . j a v a2 s .com } else if (action == Constants.ACTION_DECRYPT) { DecryptWalletTask decryptWalletTask = new DecryptWalletTask(context, wallet, password, application); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) decryptWalletTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null); else decryptWalletTask.execute(); } else if (action == Constants.ACTION_BACKUP) { BackupWalletTask backupWalletTask = new BackupWalletTask(application, context, wallet, password); //backupWalletTask.execute(); backupWalletTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null); } }
From source file:com.ruesga.rview.widget.DiffView.java
public void update() { stopTasks();/* w w w.java 2 s.c om*/ if (mDiffMode != IMAGE_MODE) { mTextDiffTask = new AsyncTextDiffProcessor(getContext(), mDiffMode, mDiffInfo, mComments, mDrafts, mBlames, mHighlightTabs, mHighlightTrailingWhitespaces, mHighlightIntralineDiffs, mTextProcessorListener); mTextDiffTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { mImageDiffTask = new AsyncImageDiffProcessor(getContext(), mLeftContent, mRightContent, mImageProcessorListener); mImageDiffTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } mBinding.setProcessing(true); mBinding.executePendingBindings(); }
From source file:joshuatee.wx.USWarningsWithRadarActivity.java
private void selectItem(int position) { mDrawerList.setItemChecked(position, false); mDrawerLayout.closeDrawer(mDrawerList); if (filter_array[position].length() != 2) { turl_local[0] = "^" + filter_array[position]; turl_local[1] = "us"; } else {/*from w w w . j a v a 2 s.com*/ turl_local[0] = ".*?"; turl_local[1] = filter_array[position].toLowerCase(Locale.US); } new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:crea.wallet.lite.service.CreativeCoinService.java
private void broadcastPeers() { if (peerGroup != null && peerGroup.isRunning()) { new AsyncTask<Void, Void, ArrayList<ConnectedPeer>>() { @Override/*from www . j a v a2 s . c om*/ protected ArrayList<ConnectedPeer> doInBackground(Void... params) { return ConnectedPeer.wrapAsList(peerGroup.getConnectedPeers()); } @Override protected void onPostExecute(ArrayList<ConnectedPeer> peers) { Intent peerIntent = new Intent(BlockchainBroadcastReceiver.ACTION_PEERS_CHANGED); peerIntent.putExtra("peers", peers); Log.e(TAG, "Broadcasting " + peers.size() + " peers"); sendBroadcast(peerIntent); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }
From source file:com.google.android.libraries.cast.companionlibrary.cast.BaseCastManager.java
/** * This method tries to automatically re-establish connection to a session if * <ul>//www.j ava 2 s. c om * <li>User had not done a manual disconnect in the last session * <li>The Cast Device that user had connected to previously is still running the same session * </ul> * Under these conditions, a best-effort attempt will be made to continue with the same * session. * This attempt will go on for <code>timeoutInSeconds</code> seconds. * * @param timeoutInSeconds the length of time, in seconds, to attempt reconnection before giving * up * @param ssidName The name of Wifi SSID */ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public void reconnectSessionIfPossible(final int timeoutInSeconds, String ssidName) { LOGD(TAG, String.format("reconnectSessionIfPossible(%d, %s)", timeoutInSeconds, ssidName)); if (isConnected()) { return; } String routeId = mPreferenceAccessor.getStringFromPreference(PREFS_KEY_ROUTE_ID); if (canConsiderSessionRecovery(ssidName)) { List<RouteInfo> routes = mMediaRouter.getRoutes(); RouteInfo theRoute = null; if (routes != null) { for (RouteInfo route : routes) { if (route.getId().equals(routeId)) { theRoute = route; break; } } } if (theRoute != null) { // route has already been discovered, so lets just get the device reconnectSessionIfPossibleInternal(theRoute); } else { // we set a flag so if the route is discovered within a short period, we let // onRouteAdded callback of CastMediaRouterCallback take care of that setReconnectionStatus(RECONNECTION_STATUS_STARTED); } // cancel any prior reconnection task if (mReconnectionTask != null && !mReconnectionTask.isCancelled()) { mReconnectionTask.cancel(true); } // we may need to reconnect to an existing session mReconnectionTask = new AsyncTask<Void, Integer, Boolean>() { @Override protected Boolean doInBackground(Void... params) { for (int i = 0; i < timeoutInSeconds; i++) { LOGD(TAG, "Reconnection: Attempt " + (i + 1)); if (isCancelled()) { return true; } try { if (isConnected()) { cancel(true); } Thread.sleep(1000); } catch (InterruptedException e) { // ignore } } return false; } @Override protected void onPostExecute(Boolean result) { if (result == null || !result) { LOGD(TAG, "Couldn't reconnect, dropping connection"); setReconnectionStatus(RECONNECTION_STATUS_INACTIVE); onDeviceSelected(null); } } }; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mReconnectionTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { mReconnectionTask.execute(); } } }
From source file:eu.faircode.netguard.Util.java
public static void sendLogcat(final Uri uri, final Context context) { AsyncTask task = new AsyncTask<Object, Object, Intent>() { @Override//w ww . java 2 s . c o m protected Intent doInBackground(Object... objects) { StringBuilder sb = new StringBuilder(); sb.append(context.getString(R.string.msg_issue)); sb.append("\r\n\r\n\r\n\r\n"); // Get version info String version = getSelfVersionName(context); sb.append(String.format("NetGuard: %s/%d\r\n", version, getSelfVersionCode(context))); sb.append(String.format("Android: %s (SDK %d)\r\n", Build.VERSION.RELEASE, Build.VERSION.SDK_INT)); sb.append("\r\n"); // Get device info sb.append(String.format("Brand: %s\r\n", Build.BRAND)); sb.append(String.format("Manufacturer: %s\r\n", Build.MANUFACTURER)); sb.append(String.format("Model: %s\r\n", Build.MODEL)); sb.append(String.format("Product: %s\r\n", Build.PRODUCT)); sb.append(String.format("Device: %s\r\n", Build.DEVICE)); sb.append(String.format("Host: %s\r\n", Build.HOST)); sb.append(String.format("Display: %s\r\n", Build.DISPLAY)); sb.append(String.format("Id: %s\r\n", Build.ID)); sb.append(String.format("Fingerprint: %B\r\n", hasValidFingerprint(context))); String abi; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) abi = Build.CPU_ABI; else abi = (Build.SUPPORTED_ABIS.length > 0 ? Build.SUPPORTED_ABIS[0] : "?"); sb.append(String.format("ABI: %s\r\n", abi)); sb.append("\r\n"); sb.append(String.format("VPN dialogs: %B\r\n", isPackageInstalled("com.android.vpndialogs", context))); try { sb.append(String.format("Prepared: %B\r\n", VpnService.prepare(context) == null)); } catch (Throwable ex) { sb.append("Prepared: ").append((ex.toString())).append("\r\n") .append(Log.getStackTraceString(ex)); } sb.append("\r\n"); sb.append(getGeneralInfo(context)); sb.append("\r\n\r\n"); sb.append(getNetworkInfo(context)); sb.append("\r\n\r\n"); // Get DNS sb.append("DNS system:\r\n"); for (String dns : getDefaultDNS(context)) sb.append("- ").append(dns).append("\r\n"); sb.append("DNS VPN:\r\n"); for (InetAddress dns : ServiceSinkhole.getDns(context)) sb.append("- ").append(dns).append("\r\n"); sb.append("\r\n"); // Get TCP connection info String line; BufferedReader in; try { sb.append("/proc/net/tcp:\r\n"); in = new BufferedReader(new FileReader("/proc/net/tcp")); while ((line = in.readLine()) != null) sb.append(line).append("\r\n"); in.close(); sb.append("\r\n"); sb.append("/proc/net/tcp6:\r\n"); in = new BufferedReader(new FileReader("/proc/net/tcp6")); while ((line = in.readLine()) != null) sb.append(line).append("\r\n"); in.close(); sb.append("\r\n"); } catch (IOException ex) { sb.append(ex.toString()).append("\r\n"); } // Get settings SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); Map<String, ?> all = prefs.getAll(); for (String key : all.keySet()) sb.append("Setting: ").append(key).append('=').append(all.get(key)).append("\r\n"); sb.append("\r\n"); // Write logcat OutputStream out = null; try { Log.i(TAG, "Writing logcat URI=" + uri); out = context.getContentResolver().openOutputStream(uri); out.write(getLogcat().toString().getBytes()); out.write(getTrafficLog(context).toString().getBytes()); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); sb.append(ex.toString()).append("\r\n").append(Log.getStackTraceString(ex)).append("\r\n"); } finally { if (out != null) try { out.close(); } catch (IOException ignored) { } } // Build intent Intent sendEmail = new Intent(Intent.ACTION_SEND); sendEmail.setType("message/rfc822"); sendEmail.putExtra(Intent.EXTRA_EMAIL, new String[] { "marcel+netguard@faircode.eu" }); sendEmail.putExtra(Intent.EXTRA_SUBJECT, "NetGuard " + version + " logcat"); sendEmail.putExtra(Intent.EXTRA_TEXT, sb.toString()); sendEmail.putExtra(Intent.EXTRA_STREAM, uri); return sendEmail; } @Override protected void onPostExecute(Intent sendEmail) { if (sendEmail != null) try { context.startActivity(sendEmail); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } } }; task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:com.google.sample.castcompanionlibrary.cast.BaseCastManager.java
/** * This method tries to automatically re-establish connection to a session if * <ul>// w w w . j av a2 s .c om * <li>User had not done a manual disconnect in the last session * <li>The Cast Device that user had connected to previously is still running the same session * </ul> * Under these conditions, a best-effort attempt will be made to continue with the same * session. * This attempt will go on for <code>timeoutInSeconds</code> seconds. * * @param timeoutInSeconds the length of time, in seconds, to attempt reconnection before giving * up * @param ssidName The name of Wifi SSID */ public void reconnectSessionIfPossible(final int timeoutInSeconds, String ssidName) { LOGD(TAG, "reconnectSessionIfPossible()"); if (isConnected()) { return; } String routeId = Utils.getStringFromPreference(mContext, PREFS_KEY_ROUTE_ID); if (canConsiderSessionRecovery(ssidName)) { List<RouteInfo> routes = mMediaRouter.getRoutes(); RouteInfo theRoute = null; if (null != routes && !routes.isEmpty()) { for (RouteInfo route : routes) { if (route.getId().equals(routeId)) { theRoute = route; break; } } } if (null != theRoute) { // route has already been discovered, so lets just get the // device, etc reconnectSessionIfPossibleInternal(theRoute); } else { // we set a flag so if the route is discovered within a short period, we let // onRouteAdded callback of CastMediaRouterCallback take care of that mReconnectionStatus = ReconnectionStatus.STARTED; onReconnectionStatusChanged(RECONNECTION_STARTED); } // cancel any prior reconnection task if (mReconnectionTask != null && !mReconnectionTask.isCancelled()) { mReconnectionTask.cancel(true); } // we may need to reconnect to an existing session mReconnectionTask = new AsyncTask<Void, Integer, Integer>() { private final int SUCCESS = 1; private final int FAILED = 2; @Override protected Integer doInBackground(Void... params) { for (int i = 0; i < timeoutInSeconds; i++) { LOGD(TAG, "Reconnection: Attempt " + (i + 1)); if (isCancelled()) { return SUCCESS; } try { if (isConnected()) { cancel(true); } Thread.sleep(1000); } catch (Exception e) { // ignore } } return FAILED; } @Override protected void onPostExecute(Integer result) { if (null != result) { if (result == FAILED) { mReconnectionStatus = ReconnectionStatus.INACTIVE; LOGD(TAG, "Couldn't reconnect, dropping connection"); onReconnectionStatusChanged(RECONNECTION_FAILED); onDeviceSelected(null); } } } }; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mReconnectionTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { mReconnectionTask.execute(); } } }
From source file:com.amaze.carbonfilemanager.activities.MainActivity.java
public void updateDrawer(String path) { new AsyncTask<String, Void, Integer>() { @Override//from w w w.ja v a 2 s .c o m protected Integer doInBackground(String... strings) { String path = strings[0]; int k = 0, i = 0; String entryItemPathOld = ""; for (Item item : dataUtils.getList()) { if (!item.isSection()) { String entryItemPath = ((EntryItem) item).getPath(); if (path.contains(((EntryItem) item).getPath())) { if (entryItemPath.length() > entryItemPathOld.length()) { // we don't need to match with the quick search drawer items // whether current entry item path is bigger than the older one found, // for eg. when we have /storage and /storage/Movies as entry items // we would choose to highlight /storage/Movies in drawer adapter k = i; entryItemPathOld = entryItemPath; } } } i++; } return k; } @Override public void onPostExecute(Integer integers) { if (adapter != null) adapter.toggleChecked(integers); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, path); }
From source file:com.instiwork.RegistrationActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_registration); callbackManager = CallbackManager.Factory.create(); pDialogOut = new ProgressDialog(RegistrationActivity.this); pDialogOut.setMessage("Signing up..."); pDialogOut.setCancelable(false);//from w w w . ja v a 2 s .c om pDialogOut.setCanceledOnTouchOutside(false); appSharedPref = getSharedPreferences("INSTIWORD", Context.MODE_PRIVATE); Picasso.with(getApplicationContext()).load(R.drawable.registrationbg).fit().centerCrop() .into((ImageView) findViewById(R.id.regbg)); dateOfBirth = (TextView) findViewById(R.id.dateofbirth); license = (RobotoLight) findViewById(R.id.license); ll_license = (LinearLayout) findViewById(R.id.ll_license); selecteddata = (RecyclerView) findViewById(R.id.selecteddat); selecteddata.setVisibility(View.GONE); gender = (RadioGroup) findViewById(R.id.gender_group); fstName = (EditText) findViewById(R.id.first_name); lastname = (EditText) findViewById(R.id.last_name); email = (EditText) findViewById(R.id.email); email_confirm = (EditText) findViewById(R.id.email_confirm); password = (EditText) findViewById(R.id.password); conformPassword = (EditText) findViewById(R.id.con_password); mobile = (EditText) findViewById(R.id.mobile); ll_image_selection = (LinearLayout) findViewById(R.id.ll_image_selection); pro_img = (ImageView) findViewById(R.id.pro_img); countryPbar = (ProgressBar) findViewById(R.id.countryPbar); country_spinner = (Spinner) findViewById(R.id.country_spinner); countryPbar.setVisibility(View.VISIBLE); country_spinner.setVisibility(View.GONE); txt_terms_conditions = (RobotoBold) findViewById(R.id.txt_terms_conditions); country_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { try { country_2_code = objectsCountry.get(position).getString("country_2_code"); country_id = objectsCountry.get(position).getString("country_id"); } catch (Exception e) { e.printStackTrace(); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); ll_image_selection.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(RegistrationActivity.this, ImageTakerActivityCamera.class); startActivityForResult(i, 1); } }); txt_terms_conditions.setText(Html.fromHtml("<u>Terms and Condition</u>")); txt_terms_conditions.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialogTermsUse(); } }); findViewById(R.id.footer).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); findViewById(R.id.help_password).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { android.app.AlertDialog.Builder alertDialogBuilder = new android.app.AlertDialog.Builder( RegistrationActivity.this); alertDialogBuilder.setTitle("Password Requirements"); alertDialogBuilder.setMessage( "Please Ensure that Password should have at least 6 characters (Maximum 20) long and it contains at least one lowercase letter, one uppercase letter, one number and one special character.") .setCancelable(false).setPositiveButton("ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); android.app.AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } }); findViewById(R.id.help_dob).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { android.app.AlertDialog.Builder alertDialogBuilder = new android.app.AlertDialog.Builder( RegistrationActivity.this); alertDialogBuilder.setTitle("Date of Birth"); alertDialogBuilder .setMessage("We require date of birth to verify that no minors are bidding on the jobs.") .setCancelable(false).setPositiveButton("ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); android.app.AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } }); findViewById(R.id.help_license).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { android.app.AlertDialog.Builder alertDialogBuilder = new android.app.AlertDialog.Builder( RegistrationActivity.this); alertDialogBuilder.setTitle("License"); alertDialogBuilder .setMessage("Please select if you have any work licenses like electrician, plumber, etc...") .setCancelable(false).setPositiveButton("ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); android.app.AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } }); gender.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { //Logger.showMessage("Geder : ", "" + checkedId); if (("" + checkedId).equalsIgnoreCase("2131558563")) {//female genderData = "" + 2; } else { genderData = "" + 1; } } }); ll_license.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(RegistrationActivity.this, LicenseActivity.class); startActivityForResult(i, 420); } }); findViewById(R.id.loginBttn).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { license_ = ""; if (fstName.getText().toString().trim().equalsIgnoreCase("")) { fstName.setError("Please enter name."); fstName.requestFocus(); } else { if (email.getText().toString().trim().equalsIgnoreCase("")) { email.setError("Please enter email."); email.requestFocus(); } else { if (android.util.Patterns.EMAIL_ADDRESS.matcher(email.getText().toString().trim()) .matches()) { if (email_confirm.getText().toString().trim().equalsIgnoreCase("")) { email_confirm.setError("Please enter email again."); email_confirm.requestFocus(); } else { if (android.util.Patterns.EMAIL_ADDRESS .matcher(email_confirm.getText().toString().trim()).matches()) { if (email.getText().toString().trim() .equalsIgnoreCase(email_confirm.getText().toString().trim())) { if (!android.util.Patterns.PHONE.matcher(mobile.getText().toString().trim()) .matches()) { mobile.setError("Please enter valid mobile number."); mobile.requestFocus(); } else { // if (password.getText().toString().trim().equalsIgnoreCase("")) { if (!isValidPassword(password.getText().toString().trim())) { password.setError( "Please Ensure that Password should have at least 6 characters (Maximum 20) long and it contains at least one lowercase letter, one uppercase letter, one number and one special character."); password.requestFocus(); } else { if (conformPassword.getText().toString().trim() .equalsIgnoreCase("")) { conformPassword.setError("Please enter password again."); conformPassword.requestFocus(); } else { if (conformPassword.getText().toString().trim() .equals(password.getText().toString().trim())) { if (dateOfBirth.getText().toString().trim() .equalsIgnoreCase("Birth date")) { Snackbar.make(findViewById(android.R.id.content), "Please select date of birth", Snackbar.LENGTH_LONG) .setActionTextColor(Color.RED).show(); } else { if (isValidDOB( dateOfBirth.getText().toString().trim())) { if (country_2_code.equalsIgnoreCase("0")) { Snackbar.make( findViewById(android.R.id.content), "Select Country From List", Snackbar.LENGTH_LONG) .setActionTextColor(Color.RED).show(); } else { if (InstiworkApplication.getInstance() .getSelectedLicenseArray() != null) { for (int i = 0; i < InstiworkApplication .getInstance() .getSelectedLicenseArray() .size(); i++) { try { if (i == 0) { license_ = license_ + InstiworkApplication .getInstance() .getSelectedLicenseArray() .get(i) .getString( "id"); } else { license_ = license_ + "," + InstiworkApplication .getInstance() .getSelectedLicenseArray() .get(i) .getString( "id"); } } catch (Exception e) { e.printStackTrace(); } } } if (((CheckBox) findViewById(R.id.trmscondi)) .isChecked()) { ll_image_selection.setEnabled(false); txt_terms_conditions.setEnabled(false); findViewById(R.id.footer).setEnabled(false); findViewById(R.id.help_password) .setEnabled(false); findViewById(R.id.help_dob) .setEnabled(false); findViewById(R.id.help_license) .setEnabled(false); ll_license.setEnabled(false); findViewById(R.id.loginBttn) .setEnabled(false); findViewById(R.id.fb_log).setEnabled(false); dateOfBirth.setEnabled(false); ll_image_selection.setClickable(false); txt_terms_conditions.setClickable(false); findViewById(R.id.footer) .setClickable(false); findViewById(R.id.help_password) .setClickable(false); findViewById(R.id.help_dob) .setClickable(false); findViewById(R.id.help_license) .setClickable(false); ll_license.setClickable(false); findViewById(R.id.loginBttn) .setClickable(false); findViewById(R.id.fb_log) .setClickable(false); dateOfBirth.setClickable(false); try { if (appSharedPref .getString("GCM_TOKEN", "") .equalsIgnoreCase("")) { String date[] = dateOfBirth .getText().toString().trim() .split("/"); final String URL = InstiworkConstants.URL_DOMAIN + "Signup_ios?name=" + URLEncoder.encode( fstName.getText() .toString() .trim(), "UTF-8") + "&contact=" + URLEncoder.encode( mobile.getText() .toString() .trim(), "UTF-8") + "&companyname=" + URLEncoder.encode( lastname.getText() .toString() .trim(), "UTF-8") + "&email=" + URLEncoder.encode( email.getText() .toString() .trim(), "UTF-8") + "&password=" + URLEncoder.encode( password.getText() .toString() .trim(), "UTF-8") + "&gender=" + genderData + "&year=" + date[2] + "&month=" + date[0] + "&date=" + date[1] + "&license=" + URLEncoder.encode( license_, "UTF-8") + "&device_type=2" + "&lat=" + LOCATION_LATITUDE + "&lng=" + LOCATION_LONGITUDE + "&country2_code=" + country_2_code + "&country_id=" + country_id + "&device_token="; (new RegistrationGCM(URL)) .executeOnExecutor( AsyncTask.THREAD_POOL_EXECUTOR); } else { gcmToken = appSharedPref .getString("GCM_TOKEN", ""); String date[] = dateOfBirth .getText().toString().trim() .split("/"); final String URL = InstiworkConstants.URL_DOMAIN + "Signup_ios?name=" + URLEncoder.encode( fstName.getText() .toString() .trim(), "UTF-8") + "&contact=" + URLEncoder.encode( mobile.getText() .toString() .trim(), "UTF-8") + "&companyname=" + URLEncoder.encode( lastname.getText() .toString() .trim(), "UTF-8") + "&email=" + URLEncoder.encode( email.getText() .toString() .trim(), "UTF-8") + "&password=" + URLEncoder.encode( password.getText() .toString() .trim(), "UTF-8") + "&gender=" + genderData + "&year=" + date[2] + "&month=" + date[0] + "&date=" + date[1] + "&license=" + license_ + "&device_type=2&device_token=" + URLEncoder.encode( gcmToken, "UTF-8") + "&lat=" + LOCATION_LATITUDE + "&lng=" + LOCATION_LONGITUDE + "&country2_code=" + country_2_code + "&country_id=" + country_id; // login_User(URL); } } catch (Exception e) { e.printStackTrace(); } } else { Snackbar.make( findViewById(android.R.id.content), "Please agree to Terms And Conditions.", Snackbar.LENGTH_LONG) .setActionTextColor(Color.RED) .show(); } } } else { Snackbar.make(findViewById(android.R.id.content), "You are under 14 years old.", Snackbar.LENGTH_LONG) .setActionTextColor(Color.RED).show(); //soutrik } } } else { conformPassword.setError( "Password amd confirm password should be same."); conformPassword.requestFocus(); } } } } } else { email_confirm.setError("Email amd confirm email should be same."); email_confirm.requestFocus(); } } else { email_confirm.setError("Please enter valid email."); email_confirm.requestFocus(); } } } else { email.setError("Please enter valid email."); email.requestFocus(); } } } } }); findViewById(R.id.fb_log).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (appSharedPref.getString("GCM_TOKEN", "").equalsIgnoreCase("")) { (new RegistrationGCMFB()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { gcmToken = appSharedPref.getString("GCM_TOKEN", ""); LoginManager.getInstance().logInWithReadPermissions(RegistrationActivity.this, Arrays.asList("public_profile", "email")); } } }); //---------Facebook LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { // App code fbAccessToken = loginResult.getAccessToken().getToken(); GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() { @Override public void onCompleted(JSONObject object, GraphResponse response) { // Log.i("FBRESULT", object.toString()); pDialogOut.setMessage("Authenticate Facebook User."); pDialogOut.show(); try { final String URL = InstiworkConstants.URL_DOMAIN + "Login_ios/checkfacebooksignup?facebook_id=" + object.getString("id") + "&device_token=" + URLEncoder.encode(gcmToken, "UTF-8") + "&device_type=2"; FB_ChkUser(URL, object); } catch (Exception e) { e.printStackTrace(); } } }); Bundle parameters = new Bundle(); parameters.putString("fields", "id,name,email,birthday,first_name,last_name,gender"); request.setParameters(parameters); request.executeAsync(); } @Override public void onCancel() { // App code pDialogOut.dismiss(); } @Override public void onError(FacebookException exception) { // App code pDialogOut.dismiss(); if (exception instanceof FacebookAuthorizationException) { if (AccessToken.getCurrentAccessToken() != null) { LoginManager.getInstance().logOut(); LoginManager.getInstance().logInWithReadPermissions(RegistrationActivity.this, Arrays.asList("public_profile", "email")); } else { // Toast.makeText(RegistrationActivity.this, "Facebook Exception : " + exception.toString(), Toast.LENGTH_SHORT).show(); } } else { // Toast.makeText(RegistrationActivity.this, "Facebook Exception : " + exception.toString(), Toast.LENGTH_SHORT).show(); } } }); dateOfBirth.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) {//soutrik Calendar today = Calendar.getInstance(); View dialoglayout = LayoutInflater.from(getApplicationContext()) .inflate(R.layout.dialog_date_picker, null); final DatePicker dPicker = (DatePicker) dialoglayout.findViewById(R.id.date_picker); dPicker.setMaxDate(today.getTimeInMillis()); // set DatePicker MAX Date today.set(dPicker.getYear(), dPicker.getMonth() + 1, dPicker.getDayOfMonth()); today.add(Calendar.YEAR, -14); dPicker.updateDate(today.get(Calendar.YEAR), today.get(Calendar.MONTH) - 1, today.get(Calendar.DATE)); AlertDialog.Builder builder = new AlertDialog.Builder(RegistrationActivity.this); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { try { SimpleDateFormat changeFormat = new SimpleDateFormat("MM/dd/yyyy"); Calendar newDate = Calendar.getInstance(); newDate.set(dPicker.getYear(), dPicker.getMonth(), dPicker.getDayOfMonth()); dateOfBirth.setText(changeFormat.format(newDate.getTime())); Logger.showMessage("DOBBBBB : ", changeFormat.format(newDate.getTime())); } catch (Exception e) { e.printStackTrace(); } } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dateOfBirth.setText("Birth date"); } }); builder.setView(dialoglayout); builder.show(); } }); // getCountryList(); buildGoogleApiClient(); if (gMapOption == null) { gMapOption = new GoogleMapOptions(); gMapOption.ambientEnabled(true); gMapOption.compassEnabled(true); } }
From source file:org.thoughtcrime.securesms.conversation.ConversationActivity.java
private void handleSelectMessageExpiration() { if (isPushGroupConversation() && !isActiveGroup()) { return;// ww w . j a v a 2s . c o m } //noinspection CodeBlock2Expr ExpirationDialog.show(this, recipient.getExpireMessages(), expirationTime -> { new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { DatabaseFactory.getRecipientDatabase(ConversationActivity.this).setExpireMessages(recipient, expirationTime); OutgoingExpirationUpdateMessage outgoingMessage = new OutgoingExpirationUpdateMessage( getRecipient(), System.currentTimeMillis(), expirationTime * 1000L); MessageSender.send(ConversationActivity.this, outgoingMessage, threadId, false, null); return null; } @Override protected void onPostExecute(Void result) { invalidateOptionsMenu(); if (fragment != null) fragment.setLastSeen(0); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }); }