List of usage examples for android.support.v4.app DialogFragment setStyle
public void setStyle(int style, int theme)
From source file:net.reichholf.dreamdroid.DreamDroid.java
public static void setDialogTheme(Context context, DialogFragment dialogFragment) { dialogFragment.setStyle(DialogFragment.STYLE_NORMAL, getDialogTheme(context)); }
From source file:org.gots.seed.view.QuickSeedActionBuilder.java
public QuickSeedActionBuilder(Context context, final SeedWidget v) { parentView = v;//w ww .j av a 2s . com mContext = context; seed = (GrowingSeedInterface) v.getTag(); quickAction = new QuickAction(mContext, QuickAction.HORIZONTAL); actionManager = GotsActionManager.getInstance().initIfNew(mContext); actionSeedManager = GotsActionSeedManager.getInstance().initIfNew(mContext); new AsyncTask<Void, Void, List<SeedActionInterface>>() { @Override protected List<SeedActionInterface> doInBackground(Void... params) { GotsActionSeedProvider helperActions = GotsActionSeedManager.getInstance().initIfNew(mContext); return helperActions.getActionsToDoBySeed(seed, false); } protected void onPostExecute(List<SeedActionInterface> actions) { for (BaseActionInterface baseActionInterface : actions) { if (!SeedActionInterface.class.isInstance(baseActionInterface)) continue; final SeedActionInterface currentAction = (SeedActionInterface) baseActionInterface; ActionWidget actionWidget = new ActionWidget(mContext, currentAction); actionWidget.setState(currentAction.getState()); quickAction.addActionItem(actionWidget); actionWidget.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new ActionTask().execute(currentAction); } }); } }; }.execute(); ScheduleAction planAction = new ScheduleAction(mContext); ActionWidget actionWidget = new ActionWidget(mContext, planAction); actionWidget.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Intent i = new Intent(mContext, NewActionActivity.class); // i.putExtra("org.gots.seed.id", seed.getGrowingSeedId()); // i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // // mContext.startActivity(i); FragmentManager fm = ((FragmentActivity) mContext).getSupportFragmentManager(); DialogFragment editNameDialog = new ScheduleActionFragment(); Bundle data = new Bundle(); data.putInt("org.gots.seed.id", seed.getGrowingSeedId()); editNameDialog.setArguments(data); editNameDialog.setStyle(DialogFragment.STYLE_NORMAL, R.style.CustomDialog); editNameDialog.show(fm, "fragment_edit_name"); quickAction.dismiss(); } }); quickAction.addActionItem(actionWidget); /* * ACTION DETAIL */ final DetailAction detail = new DetailAction(mContext); ActionWidget detailWidget = new ActionWidget(mContext, detail); detailWidget.setState(ActionState.UNDEFINED); detailWidget.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { SeedActionInterface actionItem = detail; if (DetailAction.class.isInstance(actionItem)) { // alert.show(); final Intent i = new Intent(mContext, TabSeedActivity.class); i.putExtra("org.gots.seed.id", ((GrowingSeedInterface) parentView.getTag()).getGrowingSeedId()); i.putExtra("org.gots.seed.url", ((GrowingSeedInterface) parentView.getTag()).getUrlDescription()); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(i); } else { actionItem.execute(seed); } // parentAdapter.notifyDataSetChanged(); quickAction.dismiss(); } }); quickAction.addPermanentActionItem(detailWidget); /* * ACTION WATERING */ new AsyncTask<Void, Integer, SeedActionInterface>() { @Override protected SeedActionInterface doInBackground(Void... params) { WateringAction wateringAction = (WateringAction) actionManager.getActionByName("water"); return wateringAction; } protected void onPostExecute(final SeedActionInterface action) { ActionWidget watering = new ActionWidget(mContext, action); watering.setState(ActionState.UNDEFINED); watering.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new AsyncTask<SeedActionInterface, Integer, Void>() { @Override protected Void doInBackground(SeedActionInterface... params) { SeedActionInterface actionItem = params[0]; actionItem.setDuration(0); actionItem = actionSeedManager.insertAction(seed, (BaseActionInterface) actionItem); actionSeedManager.doAction(actionItem, seed); return null; } @Override protected void onPostExecute(Void result) { Toast.makeText(mContext, "action done", Toast.LENGTH_SHORT).show(); quickAction.dismiss(); super.onPostExecute(result); } }.execute(action); } }); quickAction.addPermanentActionItem(watering); }; }.execute(); /* * ACTION DELETE */ final DeleteAction deleteAction = new DeleteAction(mContext); ActionWidget delete = new ActionWidget(mContext, deleteAction); delete.setState(ActionState.UNDEFINED); delete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setMessage(mContext.getResources().getString(R.string.action_delete_seed)) .setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { new ActionTask().execute(deleteAction); mContext.sendBroadcast(new Intent(BroadCastMessages.GROWINGSEED_DISPLAYLIST)); dialog.dismiss(); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); builder.show(); } }); quickAction.addPermanentActionItem(delete); // /* // * ACTION PHOTO // */ // new AsyncTask<Void, Integer, PhotoAction>() { // // @Override // protected PhotoAction doInBackground(Void... params) { // PhotoAction photoAction = (PhotoAction) actionManager.getActionByName("photo"); // // return photoAction; // } // // protected void onPostExecute(final PhotoAction photoAction) { // ActionWidget photoWidget = new ActionWidget(mContext, photoAction); // photoWidget.setState(ActionState.UNDEFINED); // // photoWidget.setOnClickListener(new View.OnClickListener() { // // @Override // public void onClick(View v) { // SeedActionInterface actionItem = photoAction; // if (PhotoAction.class.isInstance(actionItem)) { // // alert.show(); // final Intent i = new Intent(mContext, TabSeedActivity.class); // i.putExtra("org.gots.seed.id", ((GrowingSeedInterface) parentView.getTag()).getGrowingSeedId()); // i.putExtra("org.gots.seed.actionphoto","org.gots.seed.actionphoto"); // i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // mContext.startActivity(i); // // // // } // // parentAdapter.notifyDataSetChanged(); // quickAction.dismiss(); // } // }); // quickAction.addPermanentActionItem(photoWidget); // // }; // }.execute(); }
From source file:org.gots.ui.TabSeedActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection Intent i;/*from w ww. ja va 2 s. c o m*/ switch (item.getItemId()) { case android.R.id.home: finish(); return true; case R.id.help: Intent browserIntent = new Intent(this, WebHelpActivity.class); browserIntent.putExtra(WebHelpActivity.URL, getClass().getSimpleName()); startActivity(browserIntent); return true; case R.id.sow: Intent intent = new Intent(this, MyMainGarden.class); intent.putExtra(MyMainGarden.SELECT_ALLOTMENT, true); intent.putExtra(MyMainGarden.VENDOR_SEED_ID, mSeed.getSeedId()); startActivity(intent); return true; case R.id.planning: FragmentManager fm = getSupportFragmentManager(); DialogFragment scheduleDialog = new ScheduleActionFragment(); Bundle data = new Bundle(); data.putInt(GOTS_GROWINGSEED_ID, mSeed.getGrowingSeedId()); scheduleDialog.setArguments(data); scheduleDialog.setStyle(DialogFragment.STYLE_NORMAL, R.style.CustomDialog); scheduleDialog.show(fm, "fragment_planning"); return true; case R.id.download: new AsyncTask<Void, Integer, File>() { boolean licenceAvailable = false; IabHelper buyHelper; private ProgressDialog dialog; protected void onPreExecute() { licenceAvailable = gotsPurchase.getFeatureExportPDF() ? true : gotsPurchase.isPremium(); dialog = ProgressDialog.show(TabSeedActivity.this, "", getResources().getString(R.string.gots_loading), true); dialog.setCanceledOnTouchOutside(true); }; @Override protected File doInBackground(Void... params) { if (licenceAvailable) try { GotsActionSeedProvider provider = GotsActionSeedManager.getInstance() .initIfNew(getApplicationContext()); return provider.downloadHistory(mSeed); } catch (GotsServerRestrictedException e) { Log.w(TAG, e.getMessage()); licenceAvailable = false; return null; } return null; } @Override protected void onPostExecute(File result) { try { dialog.dismiss(); dialog = null; } catch (Exception e) { // nothing } if (!gotsPrefs.isConnectedToServer()) { AlertDialog.Builder builder = new AlertDialog.Builder(TabSeedActivity.this); builder.setMessage(getResources().getString(R.string.login_connect_restricted)) .setCancelable(false) .setPositiveButton(getResources().getString(R.string.login_connect), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { LoginDialogFragment dialogFragment = new LoginDialogFragment(); dialogFragment.show(getSupportFragmentManager(), ""); } }) .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); builder.show(); } if (!licenceAvailable) { FragmentManager fm = getSupportFragmentManager(); GotsBillingDialog editNameDialog = new GotsBillingDialog( GotsPurchaseItem.SKU_FEATURE_PDFHISTORY); editNameDialog.setStyle(DialogFragment.STYLE_NORMAL, R.style.CustomDialog); editNameDialog.show(fm, "fragment_edit_name"); } if (result != null) { Intent pdfIntent = new Intent(Intent.ACTION_VIEW); pdfIntent.setDataAndType(Uri.fromFile(result), "application/pdf"); startActivity(pdfIntent); } } }.execute(); return true; case R.id.photo: photoAction = new PhotoAction(getApplicationContext()); Date now = new Date(); cameraPicture = new File(photoAction.getImageFile(now).getAbsolutePath()); Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(cameraPicture)); // takePictureIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivityForResult(takePictureIntent, PICK_IMAGE); return true; case R.id.delete: final DeleteAction deleteAction = new DeleteAction(this); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(this.getResources().getString(R.string.action_delete_seed)).setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { new AsyncTask<SeedActionInterface, Integer, Void>() { @Override protected Void doInBackground(SeedActionInterface... params) { SeedActionInterface actionItem = params[0]; actionItem.execute(mSeed); return null; } @Override protected void onPostExecute(Void result) { Toast.makeText(getApplicationContext(), "action done", Toast.LENGTH_SHORT) .show(); TabSeedActivity.this.finish(); super.onPostExecute(result); } }.execute(deleteAction); sendBroadcast(new Intent(BroadCastMessages.GROWINGSEED_DISPLAYLIST)); dialog.dismiss(); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); builder.show(); return true; case R.id.workflow: new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { NuxeoWorkflowProvider nuxeoWorkflowProvider = new NuxeoWorkflowProvider( getApplicationContext()); // BaseSeedInterface baseSeedInterface = (BaseSeedInterface) arg0.getItemAtPosition(arg2); nuxeoWorkflowProvider.startWorkflowValidation(mSeed); return null; } }.execute(); return true; default: return super.onOptionsItemSelected(item); } }