List of usage examples for android.app Dialog findViewById
@Nullable public <T extends View> T findViewById(@IdRes int id)
From source file:com.adithya321.sharesanalysis.fragments.PurchaseShareFragment.java
private void setRecyclerViewAdapter() { sharesList = databaseHandler.getShares(); purchaseList = databaseHandler.getPurchases(); if (sharesList.size() < 1) { emptyTV.setVisibility(View.VISIBLE); arrow.setVisibility(View.VISIBLE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (getResources().getConfiguration().orientation == 1) { arrow.setBackground(getResources().getDrawable(R.drawable.curved_line_vertical)); } else { arrow.setBackground((getResources().getDrawable(R.drawable.curved_line_horizontal))); }/*from w ww.j av a 2s. c om*/ } } else { emptyTV.setVisibility(View.GONE); arrow.setVisibility(View.GONE); } PurchaseShareAdapter purchaseAdapter = new PurchaseShareAdapter(getContext(), purchaseList); purchaseAdapter.setOnItemClickListener(new PurchaseShareAdapter.OnItemClickListener() { @Override public void onItemClick(View itemView, int position) { final Purchase purchase = purchaseList.get(position); final Dialog dialog = new Dialog(getContext()); dialog.setTitle("Edit Share Purchase"); dialog.setContentView(R.layout.dialog_add_share_purchase); dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); dialog.show(); RadioButton newRB = (RadioButton) dialog.findViewById(R.id.radioBtn_new); RadioButton existingRB = (RadioButton) dialog.findViewById(R.id.radioBtn_existing); AutoCompleteTextView name = (AutoCompleteTextView) dialog.findViewById(R.id.share_name); newRB.setVisibility(View.GONE); existingRB.setChecked(true); name.setVisibility(View.GONE); final Spinner spinner = (Spinner) dialog.findViewById(R.id.existing_spinner); ArrayList<String> shares = new ArrayList<>(); int pos = 0; for (int i = 0; i < sharesList.size(); i++) { shares.add(sharesList.get(i).getName()); if (sharesList.get(i).getName().equals(purchase.getName())) pos = i; } ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, shares); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(spinnerAdapter); spinner.setSelection(pos); spinner.setVisibility(View.VISIBLE); final EditText quantity = (EditText) dialog.findViewById(R.id.no_of_shares); final EditText price = (EditText) dialog.findViewById(R.id.buying_price); quantity.setText(String.valueOf(purchase.getQuantity())); price.setText(String.valueOf(purchase.getPrice())); Calendar calendar = Calendar.getInstance(); calendar.setTime(purchase.getDate()); year_start = calendar.get(Calendar.YEAR); month_start = calendar.get(Calendar.MONTH) + 1; day_start = calendar.get(Calendar.DAY_OF_MONTH); final Button selectDate = (Button) dialog.findViewById(R.id.select_date); selectDate.setText(new StringBuilder().append(day_start).append("/").append(month_start).append("/") .append(year_start)); selectDate.setOnClickListener(PurchaseShareFragment.this); Button addPurchaseBtn = (Button) dialog.findViewById(R.id.add_purchase_btn); addPurchaseBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Purchase p = new Purchase(); p.setId(purchase.getId()); String stringStartDate = year_start + " " + month_start + " " + day_start; DateFormat format = new SimpleDateFormat("yyyy MM dd", Locale.ENGLISH); try { Date date = format.parse(stringStartDate); p.setDate(date); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Date", Toast.LENGTH_SHORT).show(); return; } try { p.setQuantity(Integer.parseInt(quantity.getText().toString())); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Number of Shares", Toast.LENGTH_SHORT).show(); return; } try { p.setPrice(Double.parseDouble(price.getText().toString())); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Buying Price", Toast.LENGTH_SHORT).show(); return; } p.setType("buy"); p.setName(spinner.getSelectedItem().toString()); databaseHandler.updatePurchase(p); setRecyclerViewAdapter(); dialog.dismiss(); } }); } }); sharePurchasesRecyclerView.setHasFixedSize(true); sharePurchasesRecyclerView.setAdapter(purchaseAdapter); sharePurchasesRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); }
From source file:com.popdeem.sdk.uikit.fragment.PDUIRewardsFragment.java
private void performRewardClick(View view) { final int position = recyclerView.getChildAdapterPosition(view); if (position == RecyclerView.NO_POSITION) { return;/*from w ww . j av a 2 s . co m*/ } final PDReward reward = mRewards.get(position); // if(BuildConfig.DEBUG){ // showDebugGratitude(reward.getId()); // return; // } if (reward.getAction().equalsIgnoreCase(PDReward.PD_REWARD_ACTION_NONE)) { final Dialog dialog = new Dialog(getActivity()); PDUIDialogUtils.setMargins(dialog, 25, 100, 25, 100); dialog.setContentView(R.layout.claim_alert_dialog); Button claim = (Button) dialog.findViewById(R.id.button_claim); Button cancel = (Button) dialog.findViewById(R.id.button_cancel); ImageView icon = (ImageView) dialog.findViewById(R.id.icon); String imageUrl = reward.getCoverImage(); if (imageUrl == null || imageUrl.isEmpty() || imageUrl.contains("default")) { Glide.with(getActivity()).load(R.drawable.pd_ui_star_icon).dontAnimate() .error(R.drawable.pd_ui_star_icon).dontAnimate().placeholder(R.drawable.pd_ui_star_icon) .into(icon); } else { Glide.with(getActivity()).load(imageUrl).dontAnimate().error(R.drawable.pd_ui_star_icon) .dontAnimate().placeholder(R.drawable.pd_ui_star_icon).into(icon); } claim.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dialog.dismiss(); claimNoActionReward(position, reward); } }); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dialog.dismiss(); } }); TextView tvTitle = dialog.findViewById(R.id.alertTitle); tvTitle.setText(reward.getDescription()); TextView message = dialog.findViewById(R.id.message); message.setText(reward.getRules()); dialog.show(); } else if (!reward.getAction().equalsIgnoreCase(PDReward.PD_REWARD_ACTION_SOCIAL_LOGIN)) { Intent intent = new Intent(getActivity(), PDUIClaimActivity.class); intent.putExtra("reward", new Gson().toJson(reward, PDReward.class)); startActivityForResult(intent, PD_CLAIM_REWARD_REQUEST_CODE); } }
From source file:mobisocial.musubi.ui.fragments.PrivacyProtectionDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog d = super.onCreateDialog(savedInstanceState); d.setContentView(R.layout.sample_stats); d.setTitle("Privacy Protection"); StringBuilder html = new StringBuilder(); html.append("<html><p>Musubi was created as a research project at the Stanford Mobisocial Computing Lab ") .append("to let users share data without an intermediary owning the data. ") .append("All the communicated data are owned by the users, stored on their own devices, and are encrypted on transit. ") .append("We help you import friends from your existing social networks like Facebook and Google, ") .append("but we do not save any of your friends' information.</p>"); html.append("</html>"); TextView sample_text = (TextView) d.findViewById(R.id.stat_text); sample_text.setText(Html.fromHtml(html.toString())); Button ok_button = (Button) d.findViewById(R.id.stat_ok); ok_button.setOnClickListener(new OnClickListener() { @Override/* www . j a v a 2s .c o m*/ public void onClick(View v) { dismiss(); } }); return d; }
From source file:com.commonsdroid.fragmentdialog.AlertFragmentDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { setCancelable(isCancelable);/* w ww . j a va 2s . c om*/ if (TextUtils.isEmpty(positiveText)) { positiveText = "OK"; Log.d("CHECK", "" + com.commonsdroid.fragmentdialog.R.string.ok); } if (TextUtils.isEmpty(negativeText)) { negativeText = "Cancel"; } switch (type) { case DIALOG_TYPE_OK: /*show dialog with positive button*/ return new AlertDialog.Builder(getActivity()).setTitle(title).setMessage(message) .setPositiveButton(positiveText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); if (alertButtonClickListener != null) alertButtonClickListener.onPositiveButtonClick(identifier); } }).create(); case DIALOG_TYPE_YES_NO: /*show dialog with positive and negative button*/ return new AlertDialog.Builder(getActivity()).setTitle(title).setMessage(message) .setPositiveButton(positiveText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); if (alertButtonClickListener != null) alertButtonClickListener.onPositiveButtonClick(identifier); } }).setNegativeButton(negativeText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); if (alertButtonClickListener != null) alertButtonClickListener.onNegativeButtonClick(identifier); } }).create(); case DATE_DIALOG: /*show date picker dialog*/ return new DatePickerDialog(getActivity(), AlertFragmentDialog.this, sYear, sMonth, sDate); case TIME_DIALOG: /*show time picker dialog*/ return new TimePickerDialog(getActivity(), AlertFragmentDialog.this, sHour, sMinute, true); case SIMPLE_LIST_DIALOG: /** * show simple list dialog */ return getAlertBuilder(title, dialogList, android.R.layout.select_dialog_item).create(); case SINGLE_CHOICE_LIST_DIALOG: /*show single choice list dialog*/ return getAlertBuilder(title, dialogList, android.R.layout.select_dialog_singlechoice).create(); case MULTI_CHOICE_LIST_DIALOG: /*show multichoice list dialog*/ Dialog multipleChoice = new Dialog(getActivity()); multipleChoice.setContentView(R.layout.list_multichoice); multipleChoice.setTitle(title); ListView listView = (ListView) multipleChoice.findViewById(R.id.lstMultichoiceList); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Manage selected items here CheckedTextView textView = (CheckedTextView) view; if (textView.isChecked()) { } else { } Log.e("CHECK", "clicked pos : " + position + " checked : " + textView.isChecked()); } }); final ArrayAdapter<String> arraySingleChoiceAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.select_dialog_multichoice, dialogList); listView.setAdapter(arraySingleChoiceAdapter); multipleChoice.show(); /*multipleChoice.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); multipleChoice.setPositiveButton(R.string.cancel, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); sListDialogListener.onMultiChoiceSelected(identifier, alSelectedItem); } });*/ /* multipleChoice.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (alSelectedItem.size() != 0) { sListDialogListener.onMultiChoiceSelected(identifier, alSelectedItem); } } });*/ // multipleChoice.create(); // singleChoiceListDialog.setCancelable(false); /* multipleChoice.setMultiChoiceItems(items, null, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { if (isChecked) { alSelectedItem.add(items[which]); } else { alSelectedItem.remove(items[which]); } } }); multipleChoice.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); multipleChoice.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (alSelectedItem.size() != 0) { sListDialogListener.onMultiChoiceSelected(identifier, alSelectedItem); } } });*/ return multipleChoice;//.create(); } return null; }
From source file:org.sufficientlysecure.keychain.ui.linked.LinkedIdCreateGithubFragment.java
public void oAuthRequest(String hostAndPath, String clientId, String scope) { Activity activity = getActivity();//from w w w .ja va 2 s . c o m if (activity == null) { return; } byte[] buf = new byte[16]; new Random().nextBytes(buf); mOAuthState = new String(Hex.encode(buf)); mOAuthCode = null; final Dialog auth_dialog = new Dialog(activity); auth_dialog.setContentView(R.layout.oauth_webview); WebView web = (WebView) auth_dialog.findViewById(R.id.web_view); web.getSettings().setSaveFormData(false); web.getSettings().setUserAgentString("OpenKeychain " + BuildConfig.VERSION_NAME); web.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { Uri uri = Uri.parse(url); if ("oauth-openkeychain".equals(uri.getScheme())) { if (mOAuthCode != null) { return true; } if (uri.getQueryParameter("error") != null) { Log.i(Constants.TAG, "got oauth error: " + uri.getQueryParameter("error")); auth_dialog.dismiss(); return true; } // check if mOAuthState == queryParam[state] mOAuthCode = uri.getQueryParameter("code"); auth_dialog.dismiss(); return true; } // don't surf away from github! if (!"github.com".equals(uri.getHost())) { auth_dialog.dismiss(); return true; } return false; } }); auth_dialog.setTitle(R.string.linked_webview_title_github); auth_dialog.setCancelable(true); auth_dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { step1GetOAuthToken(); } }); auth_dialog.show(); web.loadUrl("https://" + hostAndPath + "?client_id=" + clientId + "&scope=" + scope + "&redirect_uri=oauth-openkeychain://linked/" + "&state=" + mOAuthState); }
From source file:com.z3r0byte.magistify.DashboardActivity.java
private void relogin() { final Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.fragment_login); dialog.setTitle(R.string.msg_relogin); Button button = (Button) dialog.findViewById(R.id.button_login); button.setOnClickListener(new View.OnClickListener() { @Override//from w w w . ja va2 s . c o m public void onClick(View view) { new Thread(new Runnable() { @Override public void run() { Looper.prepare(); EditText usertxt = (EditText) dialog.findViewById(R.id.edit_text_username); EditText passwordtxt = (EditText) dialog.findViewById(R.id.edit_text_password); String username = usertxt.getText().toString(); String password = passwordtxt.getText().toString(); School school = new Gson().fromJson(configUtil.getString("School"), School.class); try { Magister magister = Magister.login(school, username, password); } catch (final IOException | NullPointerException e) { runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(DashboardActivity.this, R.string.err_no_connection, Toast.LENGTH_SHORT).show(); } }); return; } catch (ParseException e) { e.printStackTrace(); runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(DashboardActivity.this, R.string.err_unknown, Toast.LENGTH_SHORT) .show(); } }); return; } catch (InvalidParameterException e) { runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(DashboardActivity.this, R.string.err_wrong_username_or_password, Toast.LENGTH_SHORT).show(); } }); return; } Log.d(TAG, "onClick: login succeeded!"); User user = new User(username, password, false); configUtil.setString("User", new Gson().toJson(user)); configUtil.setInteger("failed_auth", 0); GlobalAccount.USER = user; dialog.dismiss(); } }).start(); } }); dialog.show(); }
From source file:com.eng.arab.translator.androidtranslator.activity.NumberViewActivity.java
public void displayDialog(String vid) { if (getResources().getIdentifier(vid, "raw", getPackageName()) == 0) { /* TEST if RAW file doesn't exist then do nothing*/ } else {/*from w w w . ja v a 2 s. c om*/ final Dialog dialog = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar); dialog.setContentView(R.layout.number_video_view); dialog.setCancelable(false); dialog.setCanceledOnTouchOutside(true); mVideoView = (VideoView) dialog.findViewById(R.id.videoView); mVideoView.setZOrderMediaOverlay(true); String path = "android.resource://" + getPackageName() + "/" + //R.raw.alif; getResources().getIdentifier(vid, "raw", getPackageName()); FrameLayout fl = (FrameLayout) dialog.findViewById(R.id.VideoFrameLayout); ImageButton imageButtonClose = (ImageButton) fl.findViewById(R.id.imageButtonClose); imageButtonClose.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //dialog.dismiss(); if (v.getId() == R.id.imageButtonClose) { dialog.dismiss(); } } // Perform button logic }); // Set the media controller buttons if (mediaController == null) { mediaController = new MediaController(NumberViewActivity.this); // Set the videoView that acts as the anchor for the MediaController. mediaController.setAnchorView(mVideoView); // Set MediaController for VideoView mVideoView.setMediaController(mediaController); } mVideoView.setVideoURI(Uri.parse(path)); mVideoView.requestFocus(); // When the video file ready for playback. mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { public void onPrepared(MediaPlayer mediaPlayer) { mVideoView.seekTo(position); if (position == 0) { mVideoView.start(); } // When video Screen change size. mediaPlayer.setOnVideoSizeChangedListener(new MediaPlayer.OnVideoSizeChangedListener() { @Override public void onVideoSizeChanged(MediaPlayer mp, int width, int height) { // Re-Set the videoView that acts as the anchor for the MediaController mediaController.setAnchorView(mVideoView); } }); } }); dialog.show(); } }
From source file:com.gunz.carrental.Fragments.CarsFragment.java
private void addCar(final boolean isAddCar, final int position) { final Dialog dialog = new Dialog(getActivity()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.custom_dialog_car); dialog.setCanceledOnTouchOutside(false); dialog.setCancelable(false);//from w w w. java 2 s.c o m TextView lblTitle = (TextView) dialog.findViewById(R.id.lblTitle); final MaterialEditText txBrand = (MaterialEditText) dialog.findViewById(R.id.txBrand); final MaterialEditText txModel = (MaterialEditText) dialog.findViewById(R.id.txModel); final MaterialEditText txLicense = (MaterialEditText) dialog.findViewById(R.id.txLicense); final MaterialEditText txFare = (MaterialEditText) dialog.findViewById(R.id.txFare); Button btnSave = (Button) dialog.findViewById(R.id.btnSave); ImageView imgClose = (ImageView) dialog.findViewById(R.id.imgClose); dialog.show(); clearErrorMsg(dialog); if (!isAddCar) { lblTitle.setText(getActivity().getResources().getString(R.string.update_car_title)); txBrand.setText(cars.get(position).brand); txModel.setText(cars.get(position).type); txLicense.setText(cars.get(position).licensePlat); txFare.setText(String.valueOf((int) cars.get(position).farePerDay)); } else { lblTitle.setText(getActivity().getResources().getString(R.string.add_new_car_title)); } btnSave.setOnClickListener(new OnOneClickListener() { @Override public void onOneClick(View v) { if (TextUtils.isEmpty(txBrand.getText().toString().trim())) { txBrand.setText(""); txBrand.setError(getActivity().getResources().getString(R.string.validation_required)); txBrand.requestFocus(); } else if (TextUtils.isEmpty(txModel.getText().toString().trim())) { txModel.setText(""); txModel.setError(getActivity().getResources().getString(R.string.validation_required)); txModel.requestFocus(); } else if (TextUtils.isEmpty(txLicense.getText().toString().trim())) { txLicense.setText(""); txLicense.setError(getActivity().getResources().getString(R.string.validation_required)); txLicense.requestFocus(); } else if (TextUtils.isEmpty(txFare.getText().toString().trim())) { txFare.setText(""); txFare.setError(getActivity().getResources().getString(R.string.validation_required)); txFare.requestFocus(); } else { String confirmText; if (isAddCar) { confirmText = getActivity().getResources().getString(R.string.dialog_add_car_question); } else { confirmText = getActivity().getResources().getString(R.string.dialog_update_car_question); } new SweetAlertDialog(getActivity(), SweetAlertDialog.NORMAL_TYPE) .setTitleText(getActivity().getResources().getString(R.string.dialog_confirmation)) .setContentText(confirmText) .setCancelText(getActivity().getResources().getString(R.string.btn_cancel)) .setConfirmText(getActivity().getResources().getString(R.string.btn_save)) .showCancelButton(true) .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { @Override public void onClick(SweetAlertDialog sweetAlertDialog) { if (isAddCar) { saveNewCar(dialog, txBrand.getText().toString().trim(), txModel.getText().toString().trim(), Integer.parseInt(txFare.getText().toString().trim()), txLicense.getText().toString().trim()); } else { updateCar(dialog, cars.get(position).id, txBrand.getText().toString().trim(), txModel.getText().toString().trim(), Integer.parseInt(txFare.getText().toString().trim()), txLicense.getText().toString().trim()); } sweetAlertDialog.dismiss(); } }).show(); } } }); imgClose.setOnClickListener(new OnOneClickListener() { @Override public void onOneClick(View v) { Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.bounce); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { dialog.dismiss(); } @Override public void onAnimationRepeat(Animation animation) { } }); v.startAnimation(animation); } }); }
From source file:com.medisa.myspacecal.MainActivity.java
@Override public void onSideNavigationItemClick(int itemId) { switch (itemId) { case R.id.side_navigation_menu_calendario: range = 0;// ww w . j a v a 2 s . c om Intent i = new Intent(this, MainActivity.class); startActivity(i); break; case R.id.side_navigation_menu_date_range: // custom dialog final Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.custom_range_date); dialog.setTitle("Data range"); // set the custom dialog components - text, image and button final DatePicker dpStart = (DatePicker) dialog.findViewById(R.id.dpStart); final DatePicker dpEnd = (DatePicker) dialog.findViewById(R.id.dpEnd); Button btnSalva = (Button) dialog.findViewById(R.id.btnSalva); final CheckBox cbIntegralBox = (CheckBox) dialog.findViewById(R.id.cbIntegral); // if button is clicked, close the custom dialog btnSalva.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dateStart = Funzioni.addZero(dpStart.getDayOfMonth(), 2) + "-" + Funzioni.addZero(dpStart.getMonth() + 1, 2) + "-" + dpStart.getYear(); dateEnd = Funzioni.addZero(dpEnd.getDayOfMonth(), 2) + "-" + Funzioni.addZero(dpEnd.getMonth() + 1, 2) + "-" + dpEnd.getYear(); Log.e(dateStart, dateEnd); if (cbIntegralBox.isChecked()) { //#########################JSON AsyncHttpClient client = new AsyncHttpClient(); client.get("http://199.180.196.10/json/integral?startdate=" + dateStart + "&enddate=" + dateEnd, new AsyncHttpResponseHandler() { @Override public void onSuccess(String response) { Log.e("SCARICATO", response + ""); JSONArray jObject; satellitiIntegral = new ArrayList<SatelliteIntegral>(); try { jObject = new JSONArray(response); for (int i = 0; i < jObject.length(); i++) { JSONArray menuObject = jObject.getJSONArray(i); String dataStart = menuObject.getString(0); String dataEnd = menuObject.getString(1); String raj2000 = menuObject.getString(2); String decj2000 = menuObject.getString(3); String target = menuObject.getString(4); Log.e("", dataStart + " " + dataEnd + " " + raj2000 + " " + decj2000 + " " + target); satellitiIntegral.add(new SatelliteIntegral(dataStart, dataEnd, raj2000, decj2000, target)); } adapter = new GridCellAdapter(getApplicationContext(), R.id.day_gridcell, month, year); adapter.notifyDataSetChanged(); calendarView.setAdapter(adapter); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } dialog.dismiss(); //############################################### // Intent mioIntent= new Intent(ctx, MainActivity.class); // startActivity(mioIntent); } }); dialog.show(); break; // case R.id.side_navigation_menu_item3: // invokeActivity(getString(R.string.title3), R.drawable.ic_android3); // break; // // case R.id.side_navigation_menu_item4: // invokeActivity(getString(R.string.title4), R.drawable.ic_android4); // break; // // case R.id.side_navigation_menu_item5: // invokeActivity(getString(R.string.title5), R.drawable.ic_android5); // break; default: return; } }
From source file:com.adithya321.sharesanalysis.fragments.FundFlowFragment.java
@Nullable @Override//w w w .ja v a2 s.com public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_fund_flow, container, false); Window window = getActivity().getWindow(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) window.setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark)); ((AppCompatActivity) getActivity()).getSupportActionBar() .setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.colorPrimary))); databaseHandler = new DatabaseHandler(getContext()); fundIn = (TextView) root.findViewById(R.id.fund_in); fundOut = (TextView) root.findViewById(R.id.fund_out); fundsListView = (ListView) root.findViewById(R.id.funds_list_view); setViews(); FloatingActionButton addFundFab = (FloatingActionButton) root.findViewById(R.id.add_fund_fab); addFundFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { final Dialog dialog = new Dialog(getContext()); dialog.setTitle("Add Fund Flow"); dialog.setContentView(R.layout.dialog_add_fund); dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); dialog.show(); Calendar calendar = Calendar.getInstance(); year_start = calendar.get(Calendar.YEAR); month_start = calendar.get(Calendar.MONTH) + 1; day_start = calendar.get(Calendar.DAY_OF_MONTH); final Button selectDate = (Button) dialog.findViewById(R.id.select_date); selectDate.setText(new StringBuilder().append(day_start).append("/").append(month_start).append("/") .append(year_start)); selectDate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Dialog dialog = new DatePickerDialog(getActivity(), onDateSetListener, year_start, month_start - 1, day_start); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { selectDate.setText(new StringBuilder().append(day_start).append("/") .append(month_start).append("/").append(year_start)); } }); dialog.show(); } }); final EditText amount = (EditText) dialog.findViewById(R.id.amount); Button addFundBtn = (Button) dialog.findViewById(R.id.add_fund_btn); addFundBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Fund fund = new Fund(); fund.setId(databaseHandler.getNextKey("fund")); String stringStartDate = year_start + " " + month_start + " " + day_start; DateFormat format = new SimpleDateFormat("yyyy MM dd", Locale.ENGLISH); try { Date date = format.parse(stringStartDate); fund.setDate(date); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Date", Toast.LENGTH_SHORT).show(); return; } try { fund.setAmount(Double.parseDouble(amount.getText().toString())); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Amount", Toast.LENGTH_SHORT).show(); return; } if (((RadioButton) dialog.findViewById(R.id.radioBtn_fund_in)).isChecked()) fund.setType("in"); else if (((RadioButton) dialog.findViewById(R.id.radioBtn_fund_out)).isChecked()) fund.setType("out"); else { Toast.makeText(getActivity(), "Invalid Fund Type", Toast.LENGTH_SHORT).show(); return; } databaseHandler.addFund(fund); setViews(); dialog.dismiss(); } }); } }); return root; }