List of usage examples for android.widget TableLayout removeAllViews
public void removeAllViews()
From source file:com.bonsai.wallet32.SendBitcoinActivity.java
private void updateAccounts() { if (mWalletService == null) return;/*w w w. j a v a 2 s . co m*/ TableLayout table = (TableLayout) findViewById(R.id.from_choices); // Clear any existing table content. table.removeAllViews(); addAccountHeader(table); mAccountIds = new ArrayList<Integer>(); // double sumbtc = 0.0; List<Balance> balances = mWalletService.getBalances(); if (balances != null) { for (Balance bal : balances) { // Our spendable balance depends on whether or not we // can spend unconfirmed balances. // long spendBalance = spendUnconfirmed() ? bal.balance : bal.available; // sumbtc += bal.balance; addAccountRow(table, bal.accountId, bal.accountName, spendBalance, mBTCFmt.fiatAtRate(spendBalance, mFiatPerBTC)); mAccountIds.add(bal.accountId); } } }
From source file:org.ementasua.SwipeyTabFragment.java
private void buildList(LayoutInflater inflater, TableLayout tl, Menu menu, boolean what, Button lunch, Button dinner, ImageView ib) { View v = null;/*from www . j a va 2s . c o m*/ boolean t = true; String tmp = ""; final String shareMsg; if (!what) { lunch.setBackgroundResource(R.drawable.table_menu_title_select); dinner.setBackgroundResource(R.drawable.table_menu_title_deselect); lunch.setClickable(false); dinner.setClickable(true); tmp = "Almo?o:\n"; } else { lunch.setBackgroundResource(R.drawable.table_menu_title_deselect); dinner.setBackgroundResource(R.drawable.table_menu_title_select); lunch.setClickable(true); dinner.setClickable(false); tmp = "Jantar:\n"; } Animation animation = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in); animation.setDuration(1000); tl.startAnimation(animation); tl.removeAllViews(); if (!menu.isDisabled()) { for (Plate p : menu.getPlates()) { if (p.getName().length() > 0 && showPlate(p)) { v = buildRow(inflater, p); if (t) v.setBackgroundResource(R.drawable.border1); else v.setBackgroundResource(R.drawable.border2); t = !t; tl.addView(v); } if (p.getType().contains("Prato") && p.getName() != "" && p.getName().length() > 0) { tmp += p.getName() + "; "; } } ib.setVisibility(View.VISIBLE); } else { v = buildRow(inflater, new Plate("", menu.getDisabledText())); v.setBackgroundResource(R.drawable.border1); tl.addView(v); ib.setVisibility(View.GONE); } shareMsg = tmp; ib.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Ementas do " + getArguments().getString("title")); String shareMessage = getArguments().getString("title") + " - " + shareMsg; shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage); startActivity(Intent.createChooser(shareIntent, "Partilhar para onde:")); } }); }
From source file:com.github.vseguip.sweet.contacts.SweetConflictResolveActivity.java
/** * @param localContacts/* w w w .j a v a2s . c om*/ * @param sugarContacts */ private void displayConflict(Map<String, ISweetContact> localContacts, Map<String, ISweetContact> sugarContacts, TableLayout fieldTable) { if (mPosResolved == 0) { mButtonPrevConflict.setVisibility(View.GONE); } else { mButtonPrevConflict.setVisibility(View.VISIBLE); } if (mPosResolved == (resolvedContacts.length - 1)) { mButtonNextConflict.setVisibility(View.GONE); } else { mButtonNextConflict.setVisibility(View.VISIBLE); } mCurrentLocal = localContacts.get(mCurrentId); mCurrentSugar = sugarContacts.get(mCurrentId); TextView titleView = (TextView) findViewById(R.id.textConflictName); titleView.setText(getString(R.string.resolve_conflict) + " (" + (mPosResolved + 1) + " of " + localContacts.size() + ")" + "\n" + mCurrentLocal.getDisplayName()); fieldTable.removeAllViews(); for (int i = 0; i < ISweetContact.COMPARISON_FIELDS.length; i++) { String field = ISweetContact.COMPARISON_FIELDS[i]; String localVal = mCurrentLocal == null ? "" : mCurrentLocal.get(field); String sugarVal = mCurrentSugar == null ? "" : mCurrentSugar.get(field); if (localVal == null) localVal = ""; if (sugarVal == null) sugarVal = ""; if (!localVal.equals(sugarVal)) addConflictRow(fieldTable, field, localVal, sugarVal); } }
From source file:com.murrayc.galaxyzoo.app.QuestionFragment.java
private void update() { final FragmentActivity activity = getActivity(); if (activity == null) return;//from w w w. j a v a 2 s .c om if (mRootView == null) { //This can happen when update() is called by the parent fragment //after this fragment has been instantiated after an orientation change, //but before onCreateView() has been called. It's not a problem //because onCreateView() will call this method again after setting mRootView. //Log.error("QuestionFragment.update(): mRootView is null."); return; } //Wipe the question details, //to ensure that we don't have old question details if somethng goes wrong when we //try to get and show the correct question details. final TextView textViewTitle = (TextView) mRootView.findViewById(R.id.textViewTitle); if (textViewTitle == null) { Log.error("update(): textViewTitle is null."); return; } textViewTitle.setText(""); //Show the text: final TextView textViewText = (TextView) mRootView.findViewById(R.id.textViewText); if (textViewText == null) { Log.error("update(): textViewText is null."); return; } textViewText.setText(""); final TableLayout layoutAnswers = (TableLayout) mRootView.findViewById(R.id.layoutAnswers); if (layoutAnswers == null) { Log.error("update(): layoutAnswers is null."); return; } layoutAnswers.removeAllViews(); if (getSingleton() == null) { //The parent fragment's onSingletonInitialized has been called //but this fragment's onSingletonInitialized hasn't been called yet. //That's OK. update() will be called, indirectly, later by this fragment's onSingletonInitialized(). return; } final DecisionTree.Question question = getQuestion(); if (question == null) { Log.error("update(): question is null."); return; } //Show the title: textViewTitle.setText(question.getTitle()); //Show the text: textViewText.setText(question.getText()); layoutAnswers.setShrinkAllColumns(true); layoutAnswers.setStretchAllColumns(true); //Checkboxes: mCheckboxButtons.clear(); final int COL_COUNT = 4; int col = 1; int rows = 0; TableRow row = null; final LayoutInflater inflater = LayoutInflater.from(activity); for (final DecisionTree.Checkbox checkbox : question.getCheckboxes()) { //Start a new row if necessary: if (row == null) { row = addRowToTable(activity, layoutAnswers); rows++; } final ToggleButton button = (ToggleButton) inflater.inflate(R.layout.question_answer_checkbox, null); //Use just the highlighting (line, color, etc) to show that it's selected, //instead of On/Off, so we don't need a separate label. //TODO: Use the icon. See http://stackoverflow.com/questions/18598255/android-create-a-toggle-button-with-image-and-no-text //TODO: Avoid the highlight bar thing at the bottom being drawn over the text. final String text = checkbox.getText(); button.setText(text); button.setTextOn(text); button.setTextOff(text); insertButtonInRow(activity, row, button); final BitmapDrawable icon = getIcon(activity, checkbox); button.setCompoundDrawables(null, icon, null, null); mCheckboxButtons.put(checkbox.getId(), button); if (col < COL_COUNT) { col++; } else { col = 1; row = null; } } //Answers: for (final DecisionTree.Answer answer : question.getAnswers()) { //Start a new row if necessary: if (row == null) { row = addRowToTable(activity, layoutAnswers); rows++; } final Button button = createAnswerButton(activity, answer); insertButtonInRow(activity, row, button); final String questionId = question.getId(); final String answerId = answer.getId(); button.setOnClickListener(new View.OnClickListener() { public void onClick(final View v) { // Perform action on click onAnswerButtonClicked(questionId, answerId); } }); if (col < COL_COUNT) { col++; } else { col = 1; row = null; } } //Add empty remaining cells, to avoid the other cells from expanding to fill the space, //because we want them to line up with the same cells above and below. if ((row != null) && (rows > 1)) { final int remaining_in_row = COL_COUNT - col + 1; for (int i = 0; i < remaining_in_row; i++) { //TODO: We could use Space instead of FrameLayout when using API>14. final FrameLayout placeholder = new FrameLayout(activity); insertButtonInRow(activity, row, placeholder); } } if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { /* This wastes even more space to be even more consistent: //Make sure there are always at least 2 rows, //so we request roughly the same amount of space each time: if (rows < 2) { row = addRowToTable(activity, layoutAnswers); final DecisionTree.Answer answer = new DecisionTree.Answer("bogus ID", "bogus title", getArbitraryIconId(), null, 0); final Button button = createAnswerButton(activity, answer); button.setVisibility(View.INVISIBLE); //It won't be seen, but it's size will be used. insertButtonInRow(activity, row, button); } */ //This will be used in a later onLayout(), //so we will know the correct height at least during the second classification, mRootView.setRowsCountForMaxHeightExperienced(rows); //Try to keep the height consistent, to avoid the user seeing everything moving about. final int min = mRootView.getMaximumHeightExperienced(rows); if (min > 0) { mRootView.setMinimumHeight(min); } } else { //Ignore any previously-set minimum height, //to stop the portrait-mode's layout from affecting the layout-mode's layout: mRootView.setMinimumHeight(0); } }
From source file:com.mobicage.rogerthat.plugins.messaging.ServiceMessageDetailActivity.java
protected void updateMessageDetail(final boolean isUpdate) { T.UI();//from w ww.ja v a 2 s. co m // Set sender avatar ImageView avatarImage = (ImageView) findViewById(R.id.avatar); String sender = mCurrentMessage.sender; setAvatar(avatarImage, sender); // Set sender name TextView senderView = (TextView) findViewById(R.id.sender); final String senderName = mFriendsPlugin.getName(sender); senderView.setText(senderName == null ? sender : senderName); // Set timestamp TextView timestampView = (TextView) findViewById(R.id.timestamp); timestampView.setText(TimeUtils.getDayTimeStr(this, mCurrentMessage.timestamp * 1000)); // Set clickable region on top to go to friends detail final RelativeLayout messageHeader = (RelativeLayout) findViewById(R.id.message_header); messageHeader.setOnClickListener(getFriendDetailOnClickListener(mCurrentMessage.sender)); messageHeader.setVisibility(View.VISIBLE); // Set message TextView messageView = (TextView) findViewById(R.id.message); WebView web = (WebView) findViewById(R.id.webview); FrameLayout flay = (FrameLayout) findViewById(R.id.message_details); Resources resources = getResources(); flay.setBackgroundColor(resources.getColor(R.color.mc_background)); boolean showBranded = false; int darkSchemeTextColor = resources.getColor(android.R.color.primary_text_dark); int lightSchemeTextColor = resources.getColor(android.R.color.primary_text_light); senderView.setTextColor(lightSchemeTextColor); timestampView.setTextColor(lightSchemeTextColor); BrandingResult br = null; if (!TextUtils.isEmptyOrWhitespace(mCurrentMessage.branding)) { boolean brandingAvailable = false; try { brandingAvailable = mMessagingPlugin.getBrandingMgr().isBrandingAvailable(mCurrentMessage.branding); } catch (BrandingFailureException e1) { L.d(e1); } try { if (brandingAvailable) { br = mMessagingPlugin.getBrandingMgr().prepareBranding(mCurrentMessage); WebSettings settings = web.getSettings(); settings.setJavaScriptEnabled(false); settings.setBlockNetworkImage(false); web.loadUrl("file://" + br.file.getAbsolutePath()); web.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); if (br.color != null) { flay.setBackgroundColor(br.color); } if (!br.showHeader) { messageHeader.setVisibility(View.GONE); MarginLayoutParams mlp = (MarginLayoutParams) web.getLayoutParams(); mlp.setMargins(0, 0, 0, mlp.bottomMargin); } else if (br.scheme == ColorScheme.dark) { senderView.setTextColor(darkSchemeTextColor); timestampView.setTextColor(darkSchemeTextColor); } showBranded = true; } else { mMessagingPlugin.getBrandingMgr().queueGenericBranding(mCurrentMessage.branding); } } catch (BrandingFailureException e) { L.bug("Could not display message with branding: branding is available, but prepareBranding failed", e); } } if (showBranded) { web.setVisibility(View.VISIBLE); messageView.setVisibility(View.GONE); } else { web.setVisibility(View.GONE); messageView.setVisibility(View.VISIBLE); messageView.setText(mCurrentMessage.message); } // Add list of members who did not ack yet FlowLayout memberSummary = (FlowLayout) findViewById(R.id.member_summary); memberSummary.removeAllViews(); SortedSet<MemberStatusTO> memberSummarySet = new TreeSet<MemberStatusTO>(getMemberstatusComparator()); for (MemberStatusTO ms : mCurrentMessage.members) { if ((ms.status & MessagingPlugin.STATUS_ACKED) != MessagingPlugin.STATUS_ACKED && !ms.member.equals(mCurrentMessage.sender)) { memberSummarySet.add(ms); } } FlowLayout.LayoutParams flowLP = new FlowLayout.LayoutParams(2, 0); for (MemberStatusTO ms : memberSummarySet) { FrameLayout fl = new FrameLayout(this); fl.setLayoutParams(flowLP); memberSummary.addView(fl); fl.addView(createParticipantView(ms)); } memberSummary.setVisibility(memberSummarySet.size() < 2 ? View.GONE : View.VISIBLE); // Add members statuses final LinearLayout members = (LinearLayout) findViewById(R.id.members); members.removeAllViews(); final String myEmail = mService.getIdentityStore().getIdentity().getEmail(); boolean isMember = false; mSomebodyAnswered = false; for (MemberStatusTO ms : mCurrentMessage.members) { boolean showMember = true; View view = getLayoutInflater().inflate(R.layout.message_member_detail, null); // Set receiver avatar RelativeLayout rl = (RelativeLayout) view.findViewById(R.id.avatar); rl.addView(createParticipantView(ms)); // Set receiver name TextView receiverView = (TextView) view.findViewById(R.id.receiver); final String memberName = mFriendsPlugin.getName(ms.member); receiverView.setText(memberName == null ? sender : memberName); // Set received timestamp TextView receivedView = (TextView) view.findViewById(R.id.received_timestamp); if ((ms.status & MessagingPlugin.STATUS_RECEIVED) == MessagingPlugin.STATUS_RECEIVED) { final String humanTime = TimeUtils.getDayTimeStr(this, ms.received_timestamp * 1000); if (ms.member.equals(mCurrentMessage.sender)) receivedView.setText(getString(R.string.sent_at, humanTime)); else receivedView.setText(getString(R.string.received_at, humanTime)); } else { receivedView.setText(R.string.not_yet_received); } // Set replied timestamp TextView repliedView = (TextView) view.findViewById(R.id.acked_timestamp); if ((ms.status & MessagingPlugin.STATUS_ACKED) == MessagingPlugin.STATUS_ACKED) { mSomebodyAnswered = true; String acked_timestamp = TimeUtils.getDayTimeStr(this, ms.acked_timestamp * 1000); if (ms.button_id != null) { ButtonTO button = null; for (ButtonTO b : mCurrentMessage.buttons) { if (b.id.equals(ms.button_id)) { button = b; break; } } if (button == null) { repliedView.setText(getString(R.string.dismissed_at, acked_timestamp)); // Do not show sender as member if he hasn't clicked a // button showMember = !ms.member.equals(mCurrentMessage.sender); } else { repliedView.setText(getString(R.string.replied_at, button.caption, acked_timestamp)); } } else { if (ms.custom_reply == null) { // Do not show sender as member if he hasn't clicked a // button showMember = !ms.member.equals(mCurrentMessage.sender); repliedView.setText(getString(R.string.dismissed_at, acked_timestamp)); } else repliedView.setText(getString(R.string.replied_at, ms.custom_reply, acked_timestamp)); } } else { repliedView.setText(R.string.not_yet_replied); showMember = !ms.member.equals(mCurrentMessage.sender); } if (br != null && br.scheme == ColorScheme.dark) { receiverView.setTextColor(darkSchemeTextColor); receivedView.setTextColor(darkSchemeTextColor); repliedView.setTextColor(darkSchemeTextColor); } else { receiverView.setTextColor(lightSchemeTextColor); receivedView.setTextColor(lightSchemeTextColor); repliedView.setTextColor(lightSchemeTextColor); } if (showMember) members.addView(view); isMember |= ms.member.equals(myEmail); } boolean isLocked = (mCurrentMessage.flags & MessagingPlugin.FLAG_LOCKED) == MessagingPlugin.FLAG_LOCKED; boolean canEdit = isMember && !isLocked; // Add attachments LinearLayout attachmentLayout = (LinearLayout) findViewById(R.id.attachment_layout); attachmentLayout.removeAllViews(); if (mCurrentMessage.attachments.length > 0) { attachmentLayout.setVisibility(View.VISIBLE); for (final AttachmentTO attachment : mCurrentMessage.attachments) { View v = getLayoutInflater().inflate(R.layout.attachment_item, null); ImageView attachment_image = (ImageView) v.findViewById(R.id.attachment_image); if (AttachmentViewerActivity.CONTENT_TYPE_JPEG.equalsIgnoreCase(attachment.content_type) || AttachmentViewerActivity.CONTENT_TYPE_PNG.equalsIgnoreCase(attachment.content_type)) { attachment_image.setImageResource(R.drawable.attachment_img); } else if (AttachmentViewerActivity.CONTENT_TYPE_PDF.equalsIgnoreCase(attachment.content_type)) { attachment_image.setImageResource(R.drawable.attachment_pdf); } else if (AttachmentViewerActivity.CONTENT_TYPE_VIDEO_MP4 .equalsIgnoreCase(attachment.content_type)) { attachment_image.setImageResource(R.drawable.attachment_video); } else { attachment_image.setImageResource(R.drawable.attachment_unknown); L.d("attachment.content_type not known: " + attachment.content_type); } TextView attachment_text = (TextView) v.findViewById(R.id.attachment_text); attachment_text.setText(attachment.name); v.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { String downloadUrlHash = mMessagingPlugin .attachmentDownloadUrlHash(attachment.download_url); File attachmentsDir; try { attachmentsDir = mMessagingPlugin.attachmentsDir(mCurrentMessage.getThreadKey(), null); } catch (IOException e) { L.d("Unable to create attachment directory", e); UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "", R.string.unable_to_read_write_sd_card); return; } boolean attachmentAvailable = mMessagingPlugin.attachmentExists(attachmentsDir, downloadUrlHash); if (!attachmentAvailable) { try { attachmentsDir = mMessagingPlugin.attachmentsDir(mCurrentMessage.getThreadKey(), mCurrentMessage.key); } catch (IOException e) { L.d("Unable to create attachment directory", e); UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "", R.string.unable_to_read_write_sd_card); return; } attachmentAvailable = mMessagingPlugin.attachmentExists(attachmentsDir, downloadUrlHash); } if (!mService.getNetworkConnectivityManager().isConnected() && !attachmentAvailable) { AlertDialog.Builder builder = new AlertDialog.Builder( ServiceMessageDetailActivity.this); builder.setMessage(R.string.no_internet_connection_try_again); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); return; } if (IOUtils.shouldCheckExternalStorageAvailable()) { String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { // Its all oke } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { if (!attachmentAvailable) { L.d("Unable to write to sd-card"); UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "", R.string.unable_to_read_write_sd_card); return; } } else { L.d("Unable to read or write to sd-card"); UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "", R.string.unable_to_read_write_sd_card); return; } } L.d("attachment.content_type: " + attachment.content_type); L.d("attachment.download_url: " + attachment.download_url); L.d("attachment.name: " + attachment.name); L.d("attachment.size: " + attachment.size); if (AttachmentViewerActivity.supportsContentType(attachment.content_type)) { Intent i = new Intent(ServiceMessageDetailActivity.this, AttachmentViewerActivity.class); i.putExtra("thread_key", mCurrentMessage.getThreadKey()); i.putExtra("message", mCurrentMessage.key); i.putExtra("content_type", attachment.content_type); i.putExtra("download_url", attachment.download_url); i.putExtra("name", attachment.name); i.putExtra("download_url_hash", downloadUrlHash); startActivity(i); } else { AlertDialog.Builder builder = new AlertDialog.Builder( ServiceMessageDetailActivity.this); builder.setMessage(getString(R.string.attachment_can_not_be_displayed_in_your_version, getString(R.string.app_name))); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); } } }); attachmentLayout.addView(v); } } else { attachmentLayout.setVisibility(View.GONE); } LinearLayout widgetLayout = (LinearLayout) findViewById(R.id.widget_layout); if (mCurrentMessage.form == null) { widgetLayout.setVisibility(View.GONE); } else { widgetLayout.setVisibility(View.VISIBLE); widgetLayout.setEnabled(canEdit); displayWidget(widgetLayout, br); } // Add buttons TableLayout tableLayout = (TableLayout) findViewById(R.id.buttons); tableLayout.removeAllViews(); for (final ButtonTO button : mCurrentMessage.buttons) { addButton(senderName, myEmail, mSomebodyAnswered, canEdit, tableLayout, button); } if (mCurrentMessage.form == null && (mCurrentMessage.flags & MessagingPlugin.FLAG_ALLOW_DISMISS) == MessagingPlugin.FLAG_ALLOW_DISMISS) { ButtonTO button = new ButtonTO(); button.caption = "Roger that!"; addButton(senderName, myEmail, mSomebodyAnswered, canEdit, tableLayout, button); } if (mCurrentMessage.broadcast_type != null) { L.d("Show broadcast spam control"); final RelativeLayout broadcastSpamControl = (RelativeLayout) findViewById(R.id.broadcast_spam_control); View broadcastSpamControlBorder = findViewById(R.id.broadcast_spam_control_border); final View broadcastSpamControlDivider = findViewById(R.id.broadcast_spam_control_divider); final LinearLayout broadcastSpamControlTextContainer = (LinearLayout) findViewById( R.id.broadcast_spam_control_text_container); TextView broadcastSpamControlText = (TextView) findViewById(R.id.broadcast_spam_control_text); final LinearLayout broadcastSpamControlSettingsContainer = (LinearLayout) findViewById( R.id.broadcast_spam_control_settings_container); TextView broadcastSpamControlSettingsText = (TextView) findViewById( R.id.broadcast_spam_control_settings_text); TextView broadcastSpamControlIcon = (TextView) findViewById(R.id.broadcast_spam_control_icon); broadcastSpamControlIcon.setTypeface(mFontAwesomeTypeFace); broadcastSpamControlIcon.setText(R.string.fa_bell); final FriendBroadcastInfo fbi = mFriendsPlugin.getFriendBroadcastFlowForMfr(mCurrentMessage.sender); if (fbi == null) { L.bug("BroadcastData was null for: " + mCurrentMessage.sender); collapseDetails(DETAIL_SECTIONS); return; } broadcastSpamControl.setVisibility(View.VISIBLE); broadcastSpamControlSettingsContainer.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { L.d("goto broadcast settings"); PressMenuIconRequestTO request = new PressMenuIconRequestTO(); request.coords = fbi.coords; request.static_flow_hash = fbi.staticFlowHash; request.hashed_tag = fbi.hashedTag; request.generation = fbi.generation; request.service = mCurrentMessage.sender; mContext = "MENU_" + UUID.randomUUID().toString(); request.context = mContext; request.timestamp = System.currentTimeMillis() / 1000; showTransmitting(null); Map<String, Object> userInput = new HashMap<String, Object>(); userInput.put("request", request.toJSONMap()); userInput.put("func", "com.mobicage.api.services.pressMenuItem"); MessageFlowRun mfr = new MessageFlowRun(); mfr.staticFlowHash = fbi.staticFlowHash; try { JsMfr.executeMfr(mfr, userInput, mService, true); } catch (EmptyStaticFlowException ex) { completeTransmit(null); AlertDialog.Builder builder = new AlertDialog.Builder(ServiceMessageDetailActivity.this); builder.setMessage(ex.getMessage()); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); return; } } }); UIUtils.showHint(this, mService, HINT_BROADCAST, R.string.hint_broadcast, mCurrentMessage.broadcast_type, mFriendsPlugin.getName(mCurrentMessage.sender)); broadcastSpamControlText .setText(getString(R.string.broadcast_subscribed_to, mCurrentMessage.broadcast_type)); broadcastSpamControlSettingsText.setText(fbi.label); int ligthAlpha = 180; int darkAlpha = 70; int alpha = ligthAlpha; if (br != null && br.scheme == ColorScheme.dark) { broadcastSpamControlIcon.setTextColor(getResources().getColor(android.R.color.black)); broadcastSpamControlBorder.setBackgroundColor(darkSchemeTextColor); broadcastSpamControlDivider.setBackgroundColor(darkSchemeTextColor); activity.setBackgroundColor(darkSchemeTextColor); broadcastSpamControlText.setTextColor(lightSchemeTextColor); broadcastSpamControlSettingsText.setTextColor(lightSchemeTextColor); int alpacolor = Color.argb(darkAlpha, Color.red(lightSchemeTextColor), Color.green(lightSchemeTextColor), Color.blue(lightSchemeTextColor)); broadcastSpamControl.setBackgroundColor(alpacolor); alpha = darkAlpha; } else { broadcastSpamControlIcon.setTextColor(getResources().getColor(android.R.color.white)); broadcastSpamControlBorder.setBackgroundColor(lightSchemeTextColor); broadcastSpamControlDivider.setBackgroundColor(lightSchemeTextColor); activity.setBackgroundColor(lightSchemeTextColor); broadcastSpamControlText.setTextColor(darkSchemeTextColor); broadcastSpamControlSettingsText.setTextColor(darkSchemeTextColor); int alpacolor = Color.argb(darkAlpha, Color.red(darkSchemeTextColor), Color.green(darkSchemeTextColor), Color.blue(darkSchemeTextColor)); broadcastSpamControl.setBackgroundColor(alpacolor); } if (br != null && br.color != null) { int alphaColor = Color.argb(alpha, Color.red(br.color), Color.green(br.color), Color.blue(br.color)); broadcastSpamControl.setBackgroundColor(alphaColor); } mService.postOnUIHandler(new SafeRunnable() { @Override protected void safeRun() throws Exception { int maxHeight = broadcastSpamControl.getHeight(); broadcastSpamControlDivider.getLayoutParams().height = maxHeight; broadcastSpamControlDivider.requestLayout(); broadcastSpamControlSettingsContainer.getLayoutParams().height = maxHeight; broadcastSpamControlSettingsContainer.requestLayout(); broadcastSpamControlTextContainer.getLayoutParams().height = maxHeight; broadcastSpamControlTextContainer.requestLayout(); int broadcastSpamControlWidth = broadcastSpamControl.getWidth(); android.view.ViewGroup.LayoutParams lp = broadcastSpamControlSettingsContainer .getLayoutParams(); lp.width = broadcastSpamControlWidth / 4; broadcastSpamControlSettingsContainer.setLayoutParams(lp); } }); } if (!isUpdate) collapseDetails(DETAIL_SECTIONS); }
From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningFragment.java
/** * Populate overzicht fragment from local member vars *///www .jav a 2 s . co m private void populateOverzichtFragment() { if (mOverzichtFragmentReady) { // TODO: show the changes in case we are editing an existing dagvergunning // koopman if (mKoopmanId > 0) { mOverzichtFragment.mKoopmanLinearLayout.setVisibility(View.VISIBLE); mOverzichtFragment.mKoopmanEmptyTextView.setVisibility(View.GONE); // koopman details mOverzichtFragment.setKoopman(mKoopmanId); // dagvergunning registratie tijd if (mRegistratieDatumtijd != null) { try { Date registratieDate = new SimpleDateFormat(getString(R.string.date_format_datumtijd), Locale.getDefault()).parse(mRegistratieDatumtijd); SimpleDateFormat sdf = new SimpleDateFormat(getString(R.string.date_format_tijd)); String registratieTijd = sdf.format(registratieDate); mOverzichtFragment.mRegistratieDatumtijdText.setText(registratieTijd); } catch (java.text.ParseException e) { Utility.log(getContext(), LOG_TAG, "Format registratie tijd failed: " + e.getMessage()); } } else { mOverzichtFragment.mRegistratieDatumtijdText.setText(""); } // dagvergunning notitie if (mNotitie != null && !mNotitie.equals("")) { mOverzichtFragment.mNotitieText.setText(getString(R.string.label_notitie) + ": " + mNotitie); Utility.collapseView(mOverzichtFragment.mNotitieText, false); } else { Utility.collapseView(mOverzichtFragment.mNotitieText, true); } // dagvergunning totale lengte if (mTotaleLengte != -1) { mOverzichtFragment.mTotaleLengte .setText(mTotaleLengte + " " + getString(R.string.length_meter)); } // registratie account naam if (mRegistratieAccountNaam != null) { mOverzichtFragment.mAccountNaam.setText(mRegistratieAccountNaam); } else { mOverzichtFragment.mAccountNaam.setText(""); } // koopman aanwezig status if (mKoopmanAanwezig != null) { // get the corresponding aanwezig title from the resource array based on the aanwezig key String[] aanwezigKeys = getResources().getStringArray(R.array.array_aanwezig_key); String[] aanwezigTitles = getResources().getStringArray(R.array.array_aanwezig_title); String aanwezigTitle = ""; for (int i = 0; i < aanwezigKeys.length; i++) { if (aanwezigKeys[i].equals(mKoopmanAanwezig)) { aanwezigTitle = aanwezigTitles[i]; } } mOverzichtFragment.mAanwezigText.setText(aanwezigTitle); } // vervanger if (mVervangerId > 0) { // hide the aanwezig status and populate and show the vervanger details mOverzichtFragment.mAanwezigText.setVisibility(View.GONE); mOverzichtFragment.mVervangerDetail.setVisibility(View.VISIBLE); mOverzichtFragment.setVervanger(mVervangerId); } else { // show the aanwezig status and hide the vervanger details mOverzichtFragment.mAanwezigText.setVisibility(View.VISIBLE); mOverzichtFragment.mVervangerDetail.setVisibility(View.GONE); } } else { mOverzichtFragment.mKoopmanEmptyTextView.setVisibility(View.VISIBLE); mOverzichtFragment.mKoopmanLinearLayout.setVisibility(View.GONE); } // product if (mErkenningsnummer != null && isProductSelected()) { // show progress bar mProgressbar.setVisibility(View.VISIBLE); // disable save function until we have a response from the api for a concept factuur mConceptFactuurDownloaded = false; // post the dagvergunning details to the api and retrieve a concept 'factuur' ApiPostDagvergunningConcept postDagvergunningConcept = new ApiPostDagvergunningConcept( getContext()); postDagvergunningConcept.setPayload(dagvergunningToJson()); postDagvergunningConcept.enqueue(new Callback<JsonObject>() { @Override public void onResponse(Response<JsonObject> response) { // hide progress bar mProgressbar.setVisibility(View.GONE); if (response.isSuccess() && response.body() != null) { mOverzichtFragment.mProductenLinearLayout.setVisibility(View.VISIBLE); mOverzichtFragment.mProductenEmptyTextView.setVisibility(View.GONE); // enable save function and give wizard next button background enabled color mConceptFactuurDownloaded = true; mWizardNextButton .setBackgroundColor(ContextCompat.getColor(getContext(), R.color.accent)); // from the response, populate the product section of the overzicht fragment View overzichtView = mOverzichtFragment.getView(); if (overzichtView != null) { // find placeholder table layout view TableLayout placeholderLayout = (TableLayout) overzichtView .findViewById(R.id.producten_placeholder); if (placeholderLayout != null) { placeholderLayout.removeAllViews(); LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); // get the producten array JsonArray producten = response.body().getAsJsonArray(getString( R.string.makkelijkemarkt_api_dagvergunning_concept_producten)); if (producten != null) { int rowCount = 0; // table header View headerLayout = layoutInflater .inflate(R.layout.dagvergunning_overzicht_product_item, null); TextView btwHeaderText = (TextView) headerLayout .findViewById(R.id.btw_totaal); btwHeaderText.setText("BTW"); TextView exclusiefHeaderText = (TextView) headerLayout .findViewById(R.id.bedrag_totaal); exclusiefHeaderText.setText("Ex. BTW"); placeholderLayout.addView(headerLayout, rowCount++); for (int i = 0; i < producten.size(); i++) { JsonObject product = producten.get(i).getAsJsonObject(); // get the product item layout View childLayout = layoutInflater .inflate(R.layout.dagvergunning_overzicht_product_item, null); // aantal if (product.get("aantal") != null && !product.get("aantal").isJsonNull()) { TextView aantalText = (TextView) childLayout .findViewById(R.id.product_aantal); aantalText.setText(product.get("aantal").getAsInt() + " x "); } // naam if (product.get("naam") != null && !product.get("naam").isJsonNull()) { TextView naamText = (TextView) childLayout .findViewById(R.id.product_naam); naamText.setText( Utility.capitalize(product.get("naam").getAsString())); } // btw % if (product.get("btw_percentage") != null && !product.get("btw_percentage").isJsonNull()) { long btwPercentage = Math.round(Double .parseDouble(product.get("btw_percentage").getAsString())); if (btwPercentage != 0) { TextView btwPercentageText = (TextView) childLayout .findViewById(R.id.btw_percentage); btwPercentageText.setText(btwPercentage + "%"); } } // btw totaal if (product.get("btw_totaal") != null && !product.get("btw_totaal").isJsonNull()) { double btwTotaalProduct = Double .parseDouble(product.get("btw_totaal").getAsString()); TextView btwTotaalText = (TextView) childLayout .findViewById(R.id.btw_totaal); if (Math.round(btwTotaalProduct) != 0) { btwTotaalText .setText(String.format(" %.2f", btwTotaalProduct)); } else { btwTotaalText.setText("-"); } } // bedrag totaal if (product.get("totaal") != null && !product.get("totaal").isJsonNull()) { double bedragTotaal = Double .parseDouble(product.get("totaal").getAsString()); TextView bedragTotaalText = (TextView) childLayout .findViewById(R.id.bedrag_totaal); bedragTotaalText.setText(String.format(" %.2f", bedragTotaal)); } // add child view placeholderLayout.addView(childLayout, rowCount++); } // exclusief double exclusief = 0; if (response.body().get("exclusief") != null && !response.body().get("exclusief").isJsonNull()) { exclusief = Double .parseDouble(response.body().get("exclusief").getAsString()); } // totaal double totaal = 0; if (response.body().get("totaal") != null && !response.body().get("totaal").isJsonNull()) { totaal = response.body().get("totaal").getAsDouble(); } // totaal btw en ex. btw View totaalLayout = layoutInflater .inflate(R.layout.dagvergunning_overzicht_product_item, null); TextView naamText = (TextView) totaalLayout.findViewById(R.id.product_naam); naamText.setText("Totaal"); TextView btwTotaalText = (TextView) totaalLayout .findViewById(R.id.btw_totaal); if (Math.round(totaal - exclusief) != 0) { btwTotaalText.setText(String.format(" %.2f", (totaal - exclusief))); } TextView exclusiefText = (TextView) totaalLayout .findViewById(R.id.bedrag_totaal); exclusiefText.setText(String.format(" %.2f", exclusief)); placeholderLayout.addView(totaalLayout, rowCount++); // separator View emptyLayout = layoutInflater .inflate(R.layout.dagvergunning_overzicht_product_item, null); placeholderLayout.addView(emptyLayout, rowCount++); // totaal inc. btw View totaalIncLayout = layoutInflater .inflate(R.layout.dagvergunning_overzicht_product_item, null); TextView totaalNaamText = (TextView) totaalIncLayout .findViewById(R.id.product_naam); totaalNaamText.setText("Totaal inc. BTW"); TextView totaalIncText = (TextView) totaalIncLayout .findViewById(R.id.bedrag_totaal); totaalIncText.setText(String.format(" %.2f", totaal)); placeholderLayout.addView(totaalIncLayout, rowCount); } } } } } @Override public void onFailure(Throwable t) { mProgressbar.setVisibility(View.GONE); } }); } else { mOverzichtFragment.mProductenLinearLayout.setVisibility(View.GONE); if (mKoopmanId > 0) { mOverzichtFragment.mProductenEmptyTextView.setVisibility(View.VISIBLE); } } } }