Example usage for android.widget LinearLayout setVisibility

List of usage examples for android.widget LinearLayout setVisibility

Introduction

In this page you can find the example usage for android.widget LinearLayout setVisibility.

Prototype

@RemotableViewMethod
public void setVisibility(@Visibility int visibility) 

Source Link

Document

Set the visibility state of this view.

Usage

From source file:com.krayzk9s.imgurholo.ui.SingleImageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    final ImgurHoloActivity activity = (ImgurHoloActivity) getActivity();
    final SharedPreferences settings = activity.getApiCall().settings;
    sort = settings.getString("CommentSort", "Best");
    boolean newData = true;
    if (commentData != null) {
        newData = false;/*  w  w w. j  av  a 2  s .  c o  m*/
    }

    mainView = inflater.inflate(R.layout.single_image_layout, container, false);
    String[] mMenuList = getResources().getStringArray(R.array.emptyList);
    if (commentAdapter == null)
        commentAdapter = new CommentAdapter(mainView.getContext());
    commentLayout = (ListView) mainView.findViewById(R.id.comment_thread);
    commentLayout.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    if (settings.getString("theme", MainActivity.HOLO_LIGHT).equals(MainActivity.HOLO_LIGHT))
        imageLayoutView = (LinearLayout) View.inflate(getActivity(), R.layout.image_view, null);
    else
        imageLayoutView = (LinearLayout) View.inflate(getActivity(), R.layout.dark_image_view, null);

    mPullToRefreshLayout = (PullToRefreshLayout) mainView.findViewById(R.id.ptr_layout);
    ActionBarPullToRefresh.from(getActivity())
            // Mark All Children as pullable
            .allChildrenArePullable()
            // Set the OnRefreshListener
            .listener(this)
            // Finally commit the setup to our PullToRefreshLayout
            .setup(mPullToRefreshLayout);
    if (savedInstanceState != null && newData) {
        imageData = savedInstanceState.getParcelable("imageData");
        inGallery = savedInstanceState.getBoolean("inGallery");
    }
    LinearLayout layout = (LinearLayout) imageLayoutView.findViewById(R.id.image_buttons);
    TextView imageDetails = (TextView) imageLayoutView.findViewById(R.id.single_image_details);
    layout.setVisibility(View.VISIBLE);
    ImageButton imageFullscreen = (ImageButton) imageLayoutView.findViewById(R.id.fullscreen);
    imageUpvote = (ImageButton) imageLayoutView.findViewById(R.id.rating_good);
    imageDownvote = (ImageButton) imageLayoutView.findViewById(R.id.rating_bad);
    ImageButton imageFavorite = (ImageButton) imageLayoutView.findViewById(R.id.rating_favorite);
    imageComment = (ImageButton) imageLayoutView.findViewById(R.id.comment);
    ImageButton imageUser = (ImageButton) imageLayoutView.findViewById(R.id.user);
    imageScore = (TextView) imageLayoutView.findViewById(R.id.single_image_score);
    TextView imageInfo = (TextView) imageLayoutView.findViewById(R.id.single_image_info);
    Log.d("imageData", imageData.getJSONObject().toString());
    if (imageData.getJSONObject().has("ups")) {
        imageUpvote.setVisibility(View.VISIBLE);
        imageDownvote.setVisibility(View.VISIBLE);
        imageScore.setVisibility(View.VISIBLE);
        imageComment.setVisibility(View.VISIBLE);
        ImageUtils.updateImageFont(imageData, imageScore);
    }
    imageInfo.setVisibility(View.VISIBLE);
    ImageUtils.updateInfoFont(imageData, imageInfo);
    imageUser.setVisibility(View.VISIBLE);
    imageFavorite.setVisibility(View.VISIBLE);
    try {
        if (!imageData.getJSONObject().has("account_url")
                || imageData.getJSONObject().getString("account_url").equals("null")
                || imageData.getJSONObject().getString("account_url").equals("[deleted]"))
            imageUser.setVisibility(View.GONE);
        if (!imageData.getJSONObject().has("vote")) {
            imageUpvote.setVisibility(View.GONE);
            imageDownvote.setVisibility(View.GONE);
        } else {
            if (imageData.getJSONObject().getString("vote") != null
                    && imageData.getJSONObject().getString("vote").equals("up"))
                imageUpvote.setImageResource(R.drawable.green_rating_good);
            else if (imageData.getJSONObject().getString("vote") != null
                    && imageData.getJSONObject().getString("vote").equals("down"))
                imageDownvote.setImageResource(R.drawable.red_rating_bad);
        }
        if (imageData.getJSONObject().getString("favorite") != null
                && imageData.getJSONObject().getBoolean("favorite"))
            imageFavorite.setImageResource(R.drawable.green_rating_favorite);
    } catch (JSONException e) {
        Log.e("Error!", e.toString());
    }
    imageFavorite.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ImageUtils.favoriteImage(singleImageFragment, imageData, (ImageButton) view, activity.getApiCall());
        }
    });
    imageUser.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ImageUtils.gotoUser(singleImageFragment, imageData);
        }
    });
    imageComment.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Activity activity = getActivity();
            final EditText newBody = new EditText(activity);
            newBody.setHint(R.string.body_hint_body);
            newBody.setLines(3);
            final TextView characterCount = new TextView(activity);
            characterCount.setText("140");
            LinearLayout commentReplyLayout = new LinearLayout(activity);
            newBody.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                    //
                }

                @Override
                public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                    characterCount.setText(String.valueOf(140 - charSequence.length()));
                }

                @Override
                public void afterTextChanged(Editable editable) {
                    for (int i = editable.length(); i > 0; i--) {
                        if (editable.subSequence(i - 1, i).toString().equals("\n"))
                            editable.replace(i - 1, i, "");
                    }
                }
            });
            commentReplyLayout.setOrientation(LinearLayout.VERTICAL);
            commentReplyLayout.addView(newBody);
            commentReplyLayout.addView(characterCount);
            new AlertDialog.Builder(activity).setTitle(R.string.dialog_comment_on_image_title)
                    .setView(commentReplyLayout)
                    .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            if (newBody.getText() != null && newBody.getText().toString().length() < 141) {
                                HashMap<String, Object> commentMap = new HashMap<String, Object>();
                                try {
                                    commentMap.put("comment", newBody.getText().toString());
                                    commentMap.put("image_id", imageData.getJSONObject().getString("id"));
                                    Fetcher fetcher = new Fetcher(singleImageFragment, "3/comment/",
                                            ApiCall.POST, commentMap,
                                            ((ImgurHoloActivity) getActivity()).getApiCall(), POSTCOMMENT);
                                    fetcher.execute();
                                } catch (JSONException e) {
                                    Log.e("Error!", e.toString());
                                }
                            }
                        }
                    }).setNegativeButton(R.string.dialog_answer_cancel, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            // Do nothing.
                        }
                    }).show();
        }
    });
    imageUpvote.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ImageUtils.upVote(singleImageFragment, imageData, imageUpvote, imageDownvote,
                    activity.getApiCall());
            ImageUtils.updateImageFont(imageData, imageScore);
        }
    });
    imageDownvote.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ImageUtils.downVote(singleImageFragment, imageData, imageUpvote, imageDownvote,
                    activity.getApiCall());
            ImageUtils.updateImageFont(imageData, imageScore);
        }
    });
    if (popupWindow != null) {
        popupWindow.dismiss();
    }
    popupWindow = new PopupWindow();
    imageFullscreen.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ImageUtils.fullscreen(singleImageFragment, imageData, popupWindow, mainView);
        }
    });
    ArrayAdapter<String> tempAdapter = new ArrayAdapter<String>(mainView.getContext(),
            R.layout.drawer_list_item, mMenuList);
    Log.d("URI", "YO I'M IN YOUR SINGLE FRAGMENT gallery:" + inGallery);
    imageView = (ImageView) imageLayoutView.findViewById(R.id.single_image_view);
    loadImage();
    TextView imageTitle = (TextView) imageLayoutView.findViewById(R.id.single_image_title);
    TextView imageDescription = (TextView) imageLayoutView.findViewById(R.id.single_image_description);

    try {
        String size = String
                .valueOf(NumberFormat.getIntegerInstance()
                        .format(imageData.getJSONObject().getInt(ImgurHoloActivity.IMAGE_DATA_WIDTH)))
                + "x"
                + NumberFormat.getIntegerInstance()
                        .format(imageData.getJSONObject().getInt(ImgurHoloActivity.IMAGE_DATA_HEIGHT))
                + " (" + NumberFormat.getIntegerInstance()
                        .format(imageData.getJSONObject().getInt(ImgurHoloActivity.IMAGE_DATA_SIZE))
                + "B)";
        String initial = imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_TYPE) + " "
                + Html.fromHtml("&#8226;") + " " + size + " " + Html.fromHtml("&#8226;") + " " + "Views: "
                + NumberFormat.getIntegerInstance()
                        .format(imageData.getJSONObject().getInt(ImgurHoloActivity.IMAGE_DATA_VIEWS));
        imageDetails.setText(initial);
        Log.d("imagedata", imageData.getJSONObject().toString());
        if (!imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_TITLE).equals("null"))
            imageTitle.setText(imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_TITLE));
        else
            imageTitle.setVisibility(View.GONE);
        if (!imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_DESCRIPTION).equals("null")) {
            imageDescription
                    .setText(imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_DESCRIPTION));
            imageDescription.setVisibility(View.VISIBLE);
        } else
            imageDescription.setVisibility(View.GONE);
        commentLayout.addHeaderView(imageLayoutView);
        commentLayout.setAdapter(tempAdapter);
    } catch (JSONException e) {
        Log.e("Text Error!", e.toString());
    }
    if ((savedInstanceState == null || commentData == null) && newData) {
        commentData = new JSONParcelable();
        getComments();
        commentLayout.setAdapter(commentAdapter);
    } else if (newData) {
        commentArray = savedInstanceState.getParcelableArrayList("commentData");
        commentAdapter.addAll(commentArray);
        commentLayout.setAdapter(commentAdapter);
        commentAdapter.notifyDataSetChanged();
    } else if (commentArray != null) {
        commentAdapter.addAll(commentArray);
        commentLayout.setAdapter(commentAdapter);
        commentAdapter.notifyDataSetChanged();
    }
    return mainView;
}

From source file:com.gh4a.IssueLabelListActivity.java

private void fillData() {
    final Typeface condensed = getApplicationContext().condensed;
    LinearLayout ll = (LinearLayout) findViewById(R.id.main_content);
    ll.removeAllViews();/*  w  ww.  ja  va2s . co  m*/

    mAllLabelLayout = new ArrayList<Map<String, Object>>();
    for (final Label label : mLabels) {
        Map<String, Object> selectedLabelItems = new HashMap<String, Object>();
        selectedLabelItems.put("label", label);

        final View rowView = getLayoutInflater().inflate(R.layout.row_issue_label, null);
        final View viewColor = (View) rowView.findViewById(R.id.view_color);

        final LinearLayout llEdit = (LinearLayout) rowView.findViewById(R.id.ll_edit);
        selectedLabelItems.put("llEdit", llEdit);

        final EditText etLabel = (EditText) rowView.findViewById(R.id.et_label);
        selectedLabelItems.put("etLabel", etLabel);

        final TextView tvLabel = (TextView) rowView.findViewById(R.id.tv_title);
        selectedLabelItems.put("tvLabel", tvLabel);

        tvLabel.setTypeface(condensed);
        tvLabel.setText(label.getName());

        viewColor.setBackgroundColor(Color.parseColor("#" + label.getColor()));
        selectedLabelItems.put("viewColor", viewColor);
        mAllLabelLayout.add(selectedLabelItems);

        viewColor.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (llEdit.getVisibility() == View.VISIBLE) {
                    llEdit.setVisibility(View.GONE);
                    unselectLabel(tvLabel, viewColor, label.getColor());
                } else {
                    llEdit.setVisibility(View.VISIBLE);
                    selectLabel(tvLabel, viewColor, label.getColor(), true, etLabel);
                    etLabel.setText(label.getName());
                    mActionMode = startActionMode(new EditActionMode(label.getName(), etLabel));
                }
            }
        });

        tvLabel.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                LinearLayout llEdit = (LinearLayout) rowView.findViewById(R.id.ll_edit);
                if (llEdit.getVisibility() == View.VISIBLE) {
                    llEdit.setVisibility(View.GONE);
                    unselectLabel(tvLabel, viewColor, label.getColor());
                } else {
                    llEdit.setVisibility(View.VISIBLE);
                    selectLabel(tvLabel, viewColor, label.getColor(), true, etLabel);
                    etLabel.setText(label.getName());
                    mActionMode = startActionMode(new EditActionMode(label.getName(), etLabel));
                }
            }
        });

        if (!StringUtils.isBlank(mSelectedLabel) && mSelectedLabel.equals(label.getName())) {
            selectLabel(tvLabel, viewColor, label.getColor(), false, etLabel);
            llEdit.setVisibility(View.VISIBLE);
            etLabel.setText(label.getName());
        }

        final View color1 = (View) rowView.findViewById(R.id.color_444444);
        color1.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                selectLabel(tvLabel, viewColor, (String) color1.getTag(), false, etLabel);
            }
        });

        final View color2 = (View) rowView.findViewById(R.id.color_02d7e1);
        color2.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                selectLabel(tvLabel, viewColor, (String) color2.getTag(), false, etLabel);
            }
        });

        final View color3 = (View) rowView.findViewById(R.id.color_02e10c);
        color3.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                selectLabel(tvLabel, viewColor, (String) color3.getTag(), false, etLabel);
            }
        });

        final View color4 = (View) rowView.findViewById(R.id.color_0b02e1);
        color4.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                selectLabel(tvLabel, viewColor, (String) color4.getTag(), false, etLabel);
            }
        });

        final View color5 = (View) rowView.findViewById(R.id.color_d7e102);
        color5.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                selectLabel(tvLabel, viewColor, (String) color5.getTag(), false, etLabel);
            }
        });

        final View color6 = (View) rowView.findViewById(R.id.color_DDDDDD);
        color6.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                selectLabel(tvLabel, viewColor, (String) color6.getTag(), false, etLabel);
            }
        });

        final View color7 = (View) rowView.findViewById(R.id.color_e102d8);
        color7.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                selectLabel(tvLabel, viewColor, (String) color7.getTag(), false, etLabel);
            }
        });

        final View color8 = (View) rowView.findViewById(R.id.color_e10c02);
        color8.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                selectLabel(tvLabel, viewColor, (String) color8.getTag(), false, etLabel);
            }
        });

        ll.addView(rowView);
    }
}

From source file:com.roamprocess1.roaming4world.ui.messages.ConversationsListFragment.java

@SuppressLint("NewApi")
@Override//from   w  ww .ja  v  a2  s.com
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
    View v = inflater.inflate(R.layout.message_list_fragment, container, false);
    LinearLayout progressContainer = (LinearLayout) v.findViewById(R.id.progressContainer);

    prefs = getActivity().getSharedPreferences("com.roamprocess1.roaming4world", Context.MODE_PRIVATE);
    stored_chatuserNumber = "com.roamprocess1.roaming4world.stored_chatuserNumber";
    stored_user_country_code = "com.roamprocess1.roaming4world.user_country_code";

    stored_account_register_status = "com.roamprocess1.roaming4world.account_register_status";
    preRegValue = prefs.getString(stored_account_register_status, "Connecting");
    System.out.println("oncreate prefValue" + preRegValue);

    LinearLayout onlinelayout = (LinearLayout) v.findViewById(R.id.onlineStatus);
    LinearLayout header_onlinelayout = (LinearLayout) v.findViewById(R.id.ll_dialer_onlineStatus);

    TextView status_register_account = (TextView) v.findViewById(R.id.status);

    ConnectivityManager connMgr1 = (ConnectivityManager) getActivity()
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo1 = connMgr1.getActiveNetworkInfo();
    if (networkInfo1 != null && networkInfo1.isConnected()) {

        if (status_register_account != null) {
            if (preRegValue.equals("Online")) {
                status_register_account.invalidate();
                onlinelayout.setBackgroundColor(Color.parseColor("#8CC63F"));
                status_register_account.setText("Online");
                status_register_account.invalidate();
                onlinelayout.setVisibility(LinearLayout.GONE);
                header_onlinelayout.setBackgroundColor(Color.parseColor("#8CC63F"));
            } else if (preRegValue.equals("Connecting")) {
                onlinelayout.setBackgroundColor(Color.parseColor("#FFA500"));
                status_register_account.setText("Connecting");
                status_register_account.invalidate();
                onlinelayout.invalidate();
                header_onlinelayout.setBackgroundColor(Color.parseColor("#FFA500"));
                onlinelayout.setVisibility(LinearLayout.GONE);
            }
        }
    } else {
        System.out.println("updateRegistrationsState() : No network");
        status_register_account.invalidate();
        onlinelayout.setBackgroundColor(Color.parseColor("#EB3D35"));
        status_register_account.setText("No Internet Connection");
        status_register_account.invalidate();
        onlinelayout.invalidate();
        onlinelayout.setVisibility(LinearLayout.GONE);
        header_onlinelayout.setBackgroundColor(Color.parseColor("#EB3D35"));

    }

    if (CurrentFragment.progressContainerLayout == false) {
        progressContainer.setVisibility(LinearLayout.GONE);
    }
    CurrentFragment.progressContainerLayout = true;

    ListView lv = (ListView) v.findViewById(android.R.id.list);

    View.OnClickListener addClickButtonListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            System.out.println("conversationsListFragment.java in oncreateview in onClick listener");
            onClickAddMessage();
        }
    };

    // Header view
    mHeaderView = (ViewGroup) inflater.inflate(R.layout.conversation_list_item, lv, false);
    ((TextView) mHeaderView.findViewById(R.id.from)).setText(R.string.new_message);
    ((TextView) mHeaderView.findViewById(R.id.subject)).setText(R.string.create_new_message);
    mHeaderView.findViewById(R.id.quick_contact_photo).setVisibility(View.GONE);
    mHeaderView.setOnClickListener(addClickButtonListener);
    // Empty view
    Button bt = (Button) v.findViewById(android.R.id.empty);

    //  bt.setOnClickListener(addClickButtonListener);
    bt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(getActivity(), MessageSipUri.class);
            getActivity().startActivity(intent);
        }
    });
    /*
    View vv = getActivity().getActionBar().getCustomView();
    imgButton_Chat = (ImageButton) vv.findViewById(R.id.imgRightMenu_chat);
    imgRightMenu = (ImageButton) vv.findViewById(R.id.imgRightMenu);
            
            
            
    imgButton_Chat.setOnClickListener(new View.OnClickListener() {
             
     @Override
     public void onClick(View v) {
    // TODO Auto-generated method stub
    onClickAddMessage();
     }
    });*/

    return v;
}

From source file:com.intuit.qboecoui.email.SalesFormEmail.java

/**
 * This method populates the form with following default data: 1. Sender's
 * address from the transaction object. 2. Subject and body of the email
 * from sales form preferences for the specific transaction. 3. Sync token
 * from the transaction.//w  w w .java 2 s  .  c o m
 *
 */
private void loadDefaultSalesFormEmailFormData() {
    if (mUri != null) {
        mTransactionManager.retrieveTransactionDetails(mUri);
    }

    TransactionData txnData = mTransactionManager.getTxnData();
    mSalesFormEmailJson.SyncToken = txnData.syncToken;

    //   TODO P2 Check what use case is this? and document this.
    if (mTransactionManager instanceof SalesReceiptManager) {
        SalesReceiptManager srManager = (SalesReceiptManager) mTransactionManager;
        if (srManager.isProcessedPayment()) {
            StringBuilder sb = new StringBuilder();
            sb.append(QBOApplicationModule.getInstance().getApplicationContext().getResources()
                    .getString(R.string.sales_form_email_payment_summary));

            String str = srManager.getTxnData().currency;
            double dbl = srManager.getTotal();
            if (str != null) {
                str = FormattingUtility.formatCurrency(dbl, str);
            } else {
                str = FormattingUtility.formatCurrency(dbl);
            }
            sb.append(String.format(QBOApplicationModule.getInstance().getApplicationContext().getResources()
                    .getString(R.string.sales_form_email_amount), str));

            if (srManager.getDateCalendar() != null) {
                long txnDate = srManager.getDateCalendar().getTimeInMillis();
                if (txnDate > 0) {
                    str = FormattingUtility.formatDate(new Date(txnDate));
                }
                sb.append(String.format("%s %s\n", getString(R.string.date_title), str));
            }
            ContactData contact = srManager.getContact();
            if (contact != null) {
                sb.append(String.format(QBOApplicationModule.getInstance().getApplicationContext()
                        .getResources().getString(R.string.sales_form_email_paid_by), contact.name));
            }
            CompanyInfoDetails companyInfo = QBCompanyInfoDataAccessor.retrieveCompanyInfo();
            String companyName = companyInfo.legalname != null ? companyInfo.legalname
                    : companyInfo.companyname;
            sb.append(String.format(QBOApplicationModule.getInstance().getApplicationContext().getResources()
                    .getString(R.string.sales_form_email_paid_to), companyName));
            if (companyInfo.legal_addr_city != null && companyInfo.legal_addr_subcode != null) {
                sb.append(
                        String.format("%s, %s\n", companyInfo.legal_addr_city, companyInfo.legal_addr_subcode));
            }

            str = CreditCardTypeUtils.parseLastFourDigits(srManager.getObfuscatedCardNumber());
            sb.append(String.format(QBOApplicationModule.getInstance().getApplicationContext().getResources()
                    .getString(R.string.sales_form_email_card), str));

            sb.append(String.format("%s: %s", getString(R.string.processed_payment_auth),
                    srManager.getPaymentAuthCode()));
            mSalesFormEmailJson.EmailMessage.Message = mSalesFormEmailJson.EmailMessage.Message
                    .concat(sb.toString());
        }
    }

    // Get the count of attachments
    int countOfAttachments = 0;
    try {
        countOfAttachments = AttachableDataAccessor.getCountOfAttachments(Long.toString(txnData.id),
                AttachableAssociation.INCLUDE_ON_SEND_URI);
    } catch (QBException QBe) {
        CustomLog.logDebug(TAG, "SalesFormEmail : " + QBe.getMessage());
    }

    final TextView attachmentCount = (TextView) findViewById(R.id.attachment_count);
    if (attachmentCount != null) {
        if (countOfAttachments == 0) {
            final LinearLayout attachmentContainer = (LinearLayout) findViewById(
                    R.id.attachment_count_container);
            if (attachmentContainer != null) {
                attachmentContainer.setVisibility(View.GONE);
            }
        } else if (countOfAttachments == 1) {
            attachmentCount.setText(getString(R.string.sales_form_email_attachment_text_1));
        } else {
            attachmentCount
                    .setText(String.format(getString(R.string.sales_form_email_attachment_text_morethan1),
                            Integer.toString(countOfAttachments)));
        }
    }

    final EditText emailReceiver = (EditText) findViewById(R.id.email_receiver);
    if (emailReceiver != null) {
        if (!TextUtils.isEmpty(txnData.mBill_email)) {
            emailReceiver.setText(txnData.mBill_email);
        } else if (txnData != null && txnData.mContact != null
                && !TextUtils.isEmpty(txnData.mContact.externalId)) {
            // Whenever the customer on the sales transaction is changed we will be changing the email address associated with the sales transaction.
            final String[] customerEmail = DataHelper.retrieveEmailAddress(
                    QBOApplicationModule.getInstance().getApplicationContext(), txnData.mContact.externalId);
            if (customerEmail != null && customerEmail.length > 0) {
                emailReceiver.setText(customerEmail[0]);
            }
        }
    }

    final EditText emailSubject = (EditText) findViewById(R.id.email_subject);
    if (emailSubject != null) {
        emailSubject.setText(mSalesFormEmailJson.EmailMessage.Subject);
    }

    final EditText emailBody = (EditText) findViewById(R.id.email_body);
    if (emailBody != null) {
        emailBody.setText(mSalesFormEmailJson.EmailMessage.Message);
    }

    // The preferences for online payment and bank payment picked up from
    // the transaction object and set on the form.
    final CompoundButton switchCreditCard = (CompoundButton) findViewById(R.id.switch_credit_card);
    mSalesFormEmailJson.AllowOnlineCreditCardPayment = Boolean
            .toString(txnData.mAllow_Online_Credit_Card_Payment);
    if (txnData.mAllow_Online_Credit_Card_Payment) {
        switchCreditCard.setChecked(true);
    } else {
        switchCreditCard.setChecked(false);
    }

    if (Util.shouldBankTransferOptionBeShown()) {
        final CompoundButton switchBankTransfer = (CompoundButton) findViewById(R.id.switch_bank_transfer);
        mSalesFormEmailJson.AllowOnlineACHPayment = Boolean.toString(txnData.getAllow_Online_Ach_Payment());
        if (txnData.getAllow_Online_Ach_Payment()) {
            switchBankTransfer.setChecked(true);
        } else {
            switchBankTransfer.setChecked(false);
        }
    }
}

From source file:com.eugene.fithealthmaingit.UI.ChooseAddMealTabsFragment.java

/**
 * Update adapters, lists, and layouts based on adapter count
 * Notifies user no items have been saved
 *//*from   www .  jav  a 2  s  . c om*/
private void updateListView() {
    LinearLayout llNoRecipes = (LinearLayout) v.findViewById(R.id.llNoRecipes);
    if (mRecentLogAdapter.getCount() != 0) {
        llNoRecentSearch.setVisibility(View.GONE);
    } else {
        llNoRecentSearch.setVisibility(View.VISIBLE);
    }

    if (mLogAdapterFavorite.getCount() != 0) {
        llNoRecentFav.setVisibility(View.GONE);
        searchFavorite.setVisibility(View.VISIBLE);
    } else {
        llNoRecentFav.setVisibility(View.VISIBLE);
        searchFavorite.setVisibility(View.GONE);
    }

    if (mLogAdapterManual.getCount() == 0) {
        llNoRecentManual.setVisibility(View.VISIBLE);
        searchManual.setVisibility(View.GONE);
    } else {
        llNoRecentManual.setVisibility(View.GONE);
        searchManual.setVisibility(View.VISIBLE);
    }
    if (logAdapterMealRecipe.getCount() == 0) {
        llNoRecipes.setVisibility(View.VISIBLE);
        listRecipes.setVisibility(View.GONE);
    } else {
        llNoRecipes.setVisibility(View.GONE);
        listRecipes.setVisibility(View.VISIBLE);
    }
}

From source file:com.money.manager.ex.home.MainActivity.java

private void initializeDrawerVariables() {
    mDrawerLayout = (LinearLayout) findViewById(R.id.linearLayoutDrawer);

    // repeating transaction
    LinearLayout mDrawerLinearRepeating = (LinearLayout) findViewById(R.id.linearLayoutRepeatingTransaction);
    if (mDrawerLinearRepeating != null) {
        mDrawerLinearRepeating.setVisibility(View.GONE);
    }//from   w  w w.j  av  a 2s. com
    mDrawerTextUserName = (TextView) findViewById(R.id.textViewUserName);
    mDrawerTextTotalAccounts = (TextView) findViewById(R.id.textViewTotalAccounts);
}

From source file:org.ednovo.goorusearchwidget.ResourcePlayer.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog = new ProgressDialog(this);
    prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    setContentViewLayout = new RelativeLayout(ResourcePlayer.this);
    prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE);

    token = prefsPrivate.getString("token", "");

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    Bundle extra = getIntent().getExtras();

    if (extra != null) {
        value = extra.getInt("key");
        gooruOID1 = extra.getStringArrayList("goor");

        searchkeyword = extra.getString("searchkey");
        limit = gooruOID1.size();//from   ww w .java  2s .  c  om
        gooruOID = gooruOID1.get(value);
        resourceGooruId = gooruOID;

        if (!gooruOID.isEmpty() || !gooruOID.equalsIgnoreCase("") || gooruOID != null) {
            if (checkInternetConnection()) {
                dialog = new ProgressDialog(ResourcePlayer.this);
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getResourcesInfo().execute();
            } else {

                dialog = new ProgressDialog(ResourcePlayer.this);
                dialog.setTitle("gooru");
                dialog.setMessage("No internet connection");
                dialog.show();
            }

        }
    }
    Editor prefsPrivateEditor = prefsPrivate.edit();

    // Authentication details
    prefsPrivateEditor.putString("searchkeyword", searchkeyword);
    prefsPrivateEditor.commit();

    wvPlayer = new WebView(ResourcePlayer.this);
    wvPlayer.resumeTimers();
    wvPlayer.getSettings().setJavaScriptEnabled(true);
    wvPlayer.getSettings().setPluginState(PluginState.ON);
    wvPlayer.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    wvPlayer.setWebViewClient(new HelloWebViewClient());

    wvPlayer.setWebChromeClient(new MyWebChromeClient() {
    });
    wvPlayer.getSettings().setPluginsEnabled(true);
    new getResourcesInfo().execute();

    RelativeLayout temp = new RelativeLayout(ResourcePlayer.this);
    temp.setId(668);
    temp.setBackgroundColor(getResources().getColor(android.R.color.transparent));

    header = new RelativeLayout(ResourcePlayer.this);
    header.setId(1);

    header.setBackgroundDrawable(getResources().getDrawable(R.drawable.navbar));
    RelativeLayout.LayoutParams headerParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, 53);
    headerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1);
    headerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, -1);

    ivCloseIcon = new ImageView(ResourcePlayer.this);
    ivCloseIcon.setId(130);
    ivCloseIcon.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams ivCloseIconIconParams = new RelativeLayout.LayoutParams(50, 50);
    ivCloseIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    ivCloseIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1);
    ivCloseIcon.setPadding(0, 0, 0, 0);

    ivCloseIcon.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            finish();

        }
    });

    ivCloseIcon.setBackgroundDrawable(getResources().getDrawable(R.drawable.close_corner));
    header.addView(ivCloseIcon, ivCloseIconIconParams);

    ivmoveforward = new ImageView(ResourcePlayer.this);
    ivmoveforward.setId(222);
    if (value == limit - 1) {
        ivmoveforward.setVisibility(View.GONE);
    }
    ivmoveforward.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams ivmoveforwardIconIconParams = new RelativeLayout.LayoutParams(21, 38);

    ivmoveforwardIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1);
    ivmoveforwardIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    ivmoveforwardIconIconParams.setMargins(0, 0, 30, 0);

    imageshare = new ImageView(ResourcePlayer.this);
    imageshare.setId(440);
    imageshare.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams imageshareIconParams = new RelativeLayout.LayoutParams(50, 50);
    imageshareIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1);
    imageshareIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    imageshareIconParams.setMargins(0, 10, 100, 0);
    tvDescriptionn = new TextView(ResourcePlayer.this);
    tvDescriptionn1 = new TextView(ResourcePlayer.this);
    edittext_copyurl = new EditText(ResourcePlayer.this);
    imageshare.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            if (desc == 0) {
                new getShortUrl().execute();

                imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_selected));

                subheader.setVisibility(View.VISIBLE);
                subheader.removeAllViews();

                tvDescriptionn.setVisibility(View.VISIBLE);
                tvDescriptionn1.setVisibility(View.VISIBLE);
                edittext_copyurl.setVisibility(View.VISIBLE);
                tvDescriptionn.setText("Share this with other by copying and pasting these links");
                tvDescriptionn.setId(221);

                tvDescriptionn.setTextSize(18);
                tvDescriptionn.setTypeface(null, Typeface.BOLD);
                tvDescriptionn.setTextColor(getResources().getColor(android.R.color.white));
                RelativeLayout.LayoutParams tvDescriptionParams = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
                tvDescriptionParams.setMargins(20, 10, 0, 20);
                subheader.addView(tvDescriptionn, tvDescriptionParams);

                tvDescriptionn1.setText("Collections");
                tvDescriptionn1.setId(226);

                tvDescriptionn1.setTextSize(18);
                tvDescriptionn1.setTypeface(null, Typeface.BOLD);
                tvDescriptionn1.setTextColor(getResources().getColor(android.R.color.white));
                RelativeLayout.LayoutParams tvDescriptionParams1 = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
                tvDescriptionParams1.setMargins(20, 42, 0, 20);
                subheader.addView(tvDescriptionn1, tvDescriptionParams1);

                edittext_copyurl.setId(266);

                edittext_copyurl.setTextSize(18);
                edittext_copyurl.setTypeface(null, Typeface.BOLD);
                edittext_copyurl.setTextColor(getResources().getColor(android.R.color.white));
                RelativeLayout.LayoutParams tvDescriptionParams11 = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
                tvDescriptionParams11.setMargins(130, 35, 0, 20);
                subheader.addView(edittext_copyurl, tvDescriptionParams11);
                desc = 1;
                flag = 0;

            } else {

                imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_normal));
                subheader.removeAllViews();
                subheader.setVisibility(View.GONE);
                desc = 0;
            }
        }
    });

    imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_normal));

    ivmoveforward.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (value < limit - 1) {
                Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class);
                Bundle extras = new Bundle();
                // extras.putString("gooruOId",s);
                extras.putStringArrayList("goor", gooruOID1);
                value++;
                extras.putInt("key", value);
                intentResPlayer.putExtras(extras);
                urlcheck = 0;
                finish();
                startActivity(intentResPlayer);
            }

        }
    });

    ivmoveforward.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrowright));

    ivmoveback = new ImageView(ResourcePlayer.this);
    ivmoveback.setId(220);
    if (value == 0) {
        ivmoveback.setVisibility(View.GONE);
    }
    ivmoveback.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams ivmovebackIconIconParams = new RelativeLayout.LayoutParams(21, 38);
    ivmovebackIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1);
    ivmovebackIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    ivmovebackIconIconParams.setMargins(55, 0, 0, 0);

    ivmoveback.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            if (!(value <= 0)) {
                value--;
                Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class);
                Bundle extras = new Bundle();
                extras.putStringArrayList("goor", gooruOID1);

                extras.putInt("key", value);
                intentResPlayer.putExtras(extras);
                urlcheck = 0;
                finish();
                startActivity(intentResPlayer);
            }

        }
    });

    ivmoveback.setBackgroundDrawable(getResources().getDrawable(R.drawable.left));

    webViewBack = new ImageView(ResourcePlayer.this);
    webViewBack.setId(323);
    webViewBack.setScaleType(ImageView.ScaleType.FIT_XY);

    RelativeLayout.LayoutParams webViewBackIconParams = new RelativeLayout.LayoutParams(25, 26);

    webViewBackIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1);
    webViewBackIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    webViewBackIconParams.setMargins(175, 0, 0, 0);

    webViewBack.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrow_leftactive));
    webViewBack.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (wvPlayer.canGoBack()) {

                wvPlayer.goBack();

            }

        }
    });

    webViewRefresh = new ImageView(ResourcePlayer.this);
    webViewRefresh.setId(322);
    webViewRefresh.setScaleType(ImageView.ScaleType.FIT_XY);

    RelativeLayout.LayoutParams webViewRefreshIconParams = new RelativeLayout.LayoutParams(30, 30);

    webViewRefreshIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1);
    webViewRefreshIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    webViewRefreshIconParams.setMargins(305, 0, 0, 0);

    webViewRefresh.setBackgroundDrawable(getResources().getDrawable(R.drawable.refresh));
    webViewRefresh.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            wvPlayer.reload();
        }
    });

    webViewForward = new ImageView(ResourcePlayer.this);
    webViewForward.setId(321);
    webViewForward.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams webViewForwardIconParams = new RelativeLayout.LayoutParams(25, 26);

    webViewForwardIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1);
    webViewForwardIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    webViewForwardIconParams.setMargins(245, 0, 0, 0);
    webViewForward.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrow_rightactive));
    webViewForward.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (wvPlayer.canGoForward()) {

                wvPlayer.goForward();

            }
        }
    });

    ivResourceIcon = new ImageView(ResourcePlayer.this);
    ivResourceIcon.setId(30);
    ivResourceIcon.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams ivResourceIconParams = new RelativeLayout.LayoutParams(50, 25);
    ivResourceIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    ivResourceIconParams.addRule(RelativeLayout.LEFT_OF, 130);
    ivResourceIcon.setPadding(50, 0, 0, 0);

    ivResourceIcon.setBackgroundDrawable(getResources().getDrawable(R.drawable.handouts));
    header.addView(ivResourceIcon, ivResourceIconParams);

    tvLearn = new TextView(this);
    tvLearn.setText("Learn More");
    tvLearn.setId(20);
    tvLearn.setPadding(100, 0, 0, 0);
    tvLearn.setTextSize(20);
    tvLearn.setTextColor(getResources().getColor(android.R.color.white));
    RelativeLayout.LayoutParams tvLearnParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    tvLearnParams.addRule(RelativeLayout.CENTER_VERTICAL, 1);
    tvLearnParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1);
    tvAbout = new ImageView(ResourcePlayer.this);
    tvAbout.setId(21);
    tvAbout.setScaleType(ImageView.ScaleType.FIT_XY);
    RelativeLayout.LayoutParams webViewForwardIconParamsa = new RelativeLayout.LayoutParams(32, 32);

    webViewForwardIconParamsa.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1);

    webViewForwardIconParamsa.addRule(RelativeLayout.CENTER_VERTICAL, -1);
    webViewForwardIconParamsa.setMargins(0, 0, 200, 0);

    tvAbout.setBackgroundDrawable(getResources().getDrawable(R.drawable.info));

    header.addView(tvAbout, webViewForwardIconParamsa);

    RelativeLayout fortvtitle = new RelativeLayout(this);
    RelativeLayout.LayoutParams tvTitleParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    tvTitleParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 1);
    tvTitleParams.addRule(RelativeLayout.CENTER_VERTICAL, 1);
    tvTitleParams.addRule(RelativeLayout.RIGHT_OF, 322);
    tvTitleParams.addRule(RelativeLayout.LEFT_OF, 21);
    header.addView(fortvtitle, tvTitleParams);

    tvTitle = new TextView(this);
    tvTitle.setText("");
    tvTitle.setId(22);
    tvTitle.setPadding(0, 0, 0, 0);
    tvTitle.setTextSize(25);
    tvTitle.setSingleLine(true);
    tvTitle.setTextColor(getResources().getColor(android.R.color.white));
    RelativeLayout.LayoutParams tvTitleParamstv = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    tvTitleParamstv.addRule(RelativeLayout.CENTER_HORIZONTAL, 1);
    tvTitleParamstv.addRule(RelativeLayout.CENTER_VERTICAL, 1);

    fortvtitle.addView(tvTitle, tvTitleParamstv);

    tvViewsNLikes = new TextView(this);
    tvViewsNLikes.setText("");
    tvViewsNLikes.setId(23);
    tvViewsNLikes.setPadding(0, 0, 5, 5);
    tvViewsNLikes.setTextSize(18);
    tvViewsNLikes.setTextColor(getResources().getColor(android.R.color.white));
    RelativeLayout.LayoutParams tvViewsNLikesParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    tvViewsNLikesParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1);
    tvViewsNLikesParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1);

    subheader = new RelativeLayout(ResourcePlayer.this);
    subheader.setId(100);
    subheader.setVisibility(View.GONE);
    subheader.setBackgroundDrawable(getResources().getDrawable(R.drawable.navbar));

    RelativeLayout.LayoutParams subheaderParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, 100);
    subheaderParams.addRule(RelativeLayout.BELOW, 1);
    subheaderParams.addRule(RelativeLayout.CENTER_IN_PARENT, 1);

    RelativeLayout.LayoutParams wvPlayerParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
    wvPlayerParams.addRule(RelativeLayout.BELOW, 100);
    wvPlayerParams.addRule(RelativeLayout.CENTER_IN_PARENT, 100);

    LinearLayout videoLayout = new LinearLayout(this);
    videoLayout.setVisibility(View.GONE);

    header.addView(webViewBack, webViewBackIconParams);
    header.addView(webViewRefresh, webViewRefreshIconParams);
    header.addView(webViewForward, webViewForwardIconParams);
    header.addView(ivmoveforward, ivmoveforwardIconIconParams);
    header.addView(imageshare, imageshareIconParams);
    header.addView(ivmoveback, ivmovebackIconIconParams);
    temp.addView(header, headerParams);
    temp.addView(subheader, subheaderParams);
    temp.addView(wvPlayer, wvPlayerParams);
    temp.addView(videoLayout, wvPlayerParams);

    setContentViewLayout.addView(temp, layoutParams);

    setContentView(setContentViewLayout);
    tvDescription = new TextView(ResourcePlayer.this);
    tvDescription1 = new TextView(ResourcePlayer.this);
    tvAbout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (flag == 0) {
                subheader.setVisibility(View.VISIBLE);
                subheader.removeAllViews();
                // tvDescriptionn.setVisibility(View.INVISIBLE);
                tvDescription1.setVisibility(View.VISIBLE);
                tvDescription.setVisibility(View.VISIBLE);

                tvDescription.setText("Description");
                tvDescription.setId(221);

                tvDescription.setTextSize(18);
                tvDescription.setTypeface(null, Typeface.BOLD);
                tvDescription.setTextColor(getResources().getColor(android.R.color.white));
                RelativeLayout.LayoutParams tvDescriptionParams = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
                tvDescriptionParams.setMargins(20, 10, 0, 20);
                tvDescriptionParams.addRule(RelativeLayout.BELOW, 220);

                tvDescription1.setText(description);
                tvDescription1.setLines(3);
                tvDescription1.setId(321);

                tvDescription1.setTextSize(15);
                tvDescription1.setTextColor(getResources().getColor(android.R.color.white));
                RelativeLayout.LayoutParams tvDescription1Params = new RelativeLayout.LayoutParams(1100, 100);
                tvDescription1Params.addRule(RelativeLayout.CENTER_IN_PARENT, -1);
                tvDescription1.setPadding(100, 20, 100, 0);
                subheader.addView(tvDescription1, tvDescription1Params);
                desc = 0;
                flag = 1;
                flag1 = 0;

            } else {
                subheader.removeAllViews();
                subheader.setVisibility(View.GONE);

                flag = 0;
            }
        }
    });

}

From source file:com.asksven.betterbatterystats.StatsActivity.java

/**
* In order to refresh the ListView we need to re-create the Adapter
* (should be the case but notifyDataSetChanged doesn't work so
* we recreate and set a new one)//from ww w . ja  va  2s. c o  m
*/
private void setListViewAdapter() throws Exception {
    LinearLayout notificationPanel = (LinearLayout) findViewById(R.id.Notification);
    ListView listView = (ListView) findViewById(android.R.id.list);

    ArrayList<StatElement> myStats = StatsProvider.getInstance().getStatList(m_iStat, m_refFromName, m_iSorting,
            m_refToName);
    if ((myStats != null) && (!myStats.isEmpty())) {
        // check if notification
        if (myStats.get(0) instanceof Notification) {
            // Show Panel
            notificationPanel.setVisibility(View.VISIBLE);
            // Hide list
            listView.setVisibility(View.GONE);

            // set Text
            TextView tvNotification = (TextView) findViewById(R.id.TextViewNotification);
            tvNotification.setText(myStats.get(0).getName());
        } else {
            // hide Panel
            notificationPanel.setVisibility(View.GONE);
            // Show list
            listView.setVisibility(View.VISIBLE);
        }
    }

    // make sure we only instanciate when the reference does not exist
    if (m_listViewAdapter == null) {
        m_listViewAdapter = new StatsAdapter(this, myStats, StatsActivity.this);
        Reference myReferenceFrom = ReferenceStore.getReferenceByName(m_refFromName, StatsActivity.this);
        Reference myReferenceTo = ReferenceStore.getReferenceByName(m_refToName, StatsActivity.this);

        long sinceMs = StatsProvider.getInstance().getSince(myReferenceFrom, myReferenceTo);
        m_listViewAdapter.setTotalTime(sinceMs);

        setListAdapter(m_listViewAdapter);
    }
}

From source file:net.olejon.mdapp.MedicationFelleskatalogenFragment.java

@SuppressLint("SetJavaScriptEnabled")
@Override//w  w  w  . j  a v a2 s  . c om
public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) {
    ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_medication_felleskatalogen, container,
            false);

    // Activity
    final Activity activity = getActivity();

    // Context
    final Context context = activity.getApplicationContext();

    // Tools
    final MyTools mTools = new MyTools(context);

    // Arguments
    Bundle bundle = getArguments();

    final String pageUri = bundle.getString("uri");

    // Progress bar
    final ProgressBar progressBar = (ProgressBar) activity
            .findViewById(R.id.medication_toolbar_progressbar_horizontal);

    // Toolbar
    final LinearLayout toolbarSearchLayout = (LinearLayout) activity
            .findViewById(R.id.medication_toolbar_search_layout);
    final EditText toolbarSearchEditText = (EditText) activity.findViewById(R.id.medication_toolbar_search);

    // Web view
    WEBVIEW = (WebView) viewGroup.findViewById(R.id.medication_felleskatalogen_content);

    WebSettings webSettings = WEBVIEW.getSettings();
    webSettings.setJavaScriptEnabled(true);

    WEBVIEW.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (!mTools.isDeviceConnected()) {
                mTools.showToast(getString(R.string.device_not_connected), 0);
                return true;
            } else if (url.matches("^https?://.*?\\.pdf$")) {
                mTools.downloadFile(view.getTitle(), url);
                return true;
            }

            return false;
        }
    });

    WEBVIEW.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            if (newProgress == 100) {
                progressBar.setVisibility(View.INVISIBLE);
            } else {
                progressBar.setVisibility(View.VISIBLE);
                progressBar.setProgress(newProgress);

                toolbarSearchLayout.setVisibility(View.GONE);
                toolbarSearchEditText.setText("");
            }
        }
    });

    if (savedInstanceState == null) {
        WEBVIEW.loadUrl(pageUri);
    } else {
        WEBVIEW.restoreState(savedInstanceState);
    }

    return viewGroup;
}

From source file:com.cypress.cysmart.BLEServiceFragments.FindMeService.java

/**
 * Method to get required characteristics from service
 *///from ww w  .j  a  v a2s.c  om
private void getGattData() {
    LinearLayout ll_layout = (LinearLayout) rootView.findViewById(R.id.linkloss_layout);
    LinearLayout im_layout = (LinearLayout) rootView.findViewById(R.id.immalert_layout);
    LinearLayout tp_layout = (LinearLayout) rootView.findViewById(R.id.transmission_layout);
    RelativeLayout tpr_layout = (RelativeLayout) rootView.findViewById(R.id.transmission_rel_layout);

    for (int position = 0; position < mExtraservice.size(); position++) {
        HashMap<String, BluetoothGattService> item = mExtraservice.get(position);
        BluetoothGattService bgs = item.get("UUID");
        List<BluetoothGattCharacteristic> gattCharacteristicsCurrent = bgs.getCharacteristics();
        for (final BluetoothGattCharacteristic gattCharacteristic : gattCharacteristicsCurrent) {
            String uuidchara = gattCharacteristic.getUuid().toString();
            if (uuidchara.equalsIgnoreCase(GattAttributes.ALERT_LEVEL)) {
                if (bgs.getUuid().toString().equalsIgnoreCase(GattAttributes.LINK_LOSS_SERVICE)) {
                    ll_layout.setVisibility(View.VISIBLE);
                    mSpinnerLinkLoss = (CustomSpinner) rootView.findViewById(R.id.linkloss_spinner);
                    // Create an ArrayAdapter using the string array and a
                    // default
                    // spinner layout
                    ArrayAdapter<CharSequence> adapter_linkloss = ArrayAdapter.createFromResource(getActivity(),
                            R.array.findme_immediate_alert_array, android.R.layout.simple_spinner_item);
                    // Specify the layout to use when the list of choices
                    // appears
                    adapter_linkloss.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                    // Apply the adapter to the spinner
                    mSpinnerLinkLoss.setAdapter(adapter_linkloss);
                    mSpinnerLinkLoss.setOnItemSelectedListener(new OnItemSelectedListener() {

                        @Override
                        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

                            if (parent.getItemAtPosition(position).toString().equalsIgnoreCase("No Alert")) {
                                byte[] convertedBytes = convertingTobyteArray(IMM_NO_ALERT);
                                BluetoothLeService.writeCharacteristicNoresponse(gattCharacteristic,
                                        convertedBytes);
                                Toast.makeText(getActivity(),
                                        getResources().getString(R.string.find_value_written_toast)
                                                + IMM_NO_ALERT_TEXT
                                                + getResources().getString(R.string.find_value_success_toast),
                                        Toast.LENGTH_SHORT).show();
                            }
                            if (parent.getItemAtPosition(position).toString().equalsIgnoreCase("Mid Alert")) {
                                byte[] convertedBytes = convertingTobyteArray(IMM_MID_ALERT);
                                BluetoothLeService.writeCharacteristicNoresponse(gattCharacteristic,
                                        convertedBytes);
                                Toast.makeText(getActivity(),
                                        getResources().getString(R.string.find_value_written_toast)
                                                + IMM_MID_ALERT_TEXT
                                                + getResources().getString(R.string.find_value_success_toast),
                                        Toast.LENGTH_SHORT).show();
                            }
                            if (parent.getItemAtPosition(position).toString().equalsIgnoreCase("High Alert")) {
                                byte[] convertedBytes = convertingTobyteArray(IMM_HIGH_ALERT);
                                BluetoothLeService.writeCharacteristicNoresponse(gattCharacteristic,
                                        convertedBytes);
                                Toast.makeText(getActivity(),
                                        getResources().getString(R.string.find_value_written_toast)
                                                + IMM_HIGH_ALERT_TEXT
                                                + getResources().getString(R.string.find_value_success_toast),
                                        Toast.LENGTH_SHORT).show();
                            }

                        }

                        @Override
                        public void onNothingSelected(AdapterView<?> parent) {
                            // TODO Auto-generated method stub

                        }
                    });
                }
                if (bgs.getUuid().toString().equalsIgnoreCase(GattAttributes.IMMEDIATE_ALERT_SERVICE)) {
                    im_layout.setVisibility(View.VISIBLE);
                    mSpinnerImmediateAlert = (CustomSpinner) rootView.findViewById(R.id.immediate_spinner);
                    // Create an ArrayAdapter using the string array and a
                    // default
                    // spinner layout
                    ArrayAdapter<CharSequence> adapter_immediate_alert = ArrayAdapter.createFromResource(
                            getActivity(), R.array.findme_immediate_alert_array,
                            android.R.layout.simple_spinner_item);
                    // Specify the layout to use when the list of choices
                    // appears
                    adapter_immediate_alert
                            .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                    // Apply the adapter to the spinner
                    mSpinnerImmediateAlert.setAdapter(adapter_immediate_alert);
                    mSpinnerImmediateAlert.setOnItemSelectedListener(new OnItemSelectedListener() {

                        @Override
                        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

                            if (parent.getItemAtPosition(position).toString().equalsIgnoreCase("No Alert")) {
                                byte[] convertedBytes = convertingTobyteArray(IMM_NO_ALERT);
                                BluetoothLeService.writeCharacteristicNoresponse(gattCharacteristic,
                                        convertedBytes);
                                Toast.makeText(getActivity(),
                                        getResources().getString(R.string.find_value_written_toast)
                                                + IMM_NO_ALERT_TEXT
                                                + getResources().getString(R.string.find_value_success_toast),
                                        Toast.LENGTH_SHORT).show();
                            }
                            if (parent.getItemAtPosition(position).toString().equalsIgnoreCase("Mid Alert")) {
                                byte[] convertedBytes = convertingTobyteArray(IMM_MID_ALERT);
                                BluetoothLeService.writeCharacteristicNoresponse(gattCharacteristic,
                                        convertedBytes);
                                Toast.makeText(getActivity(),
                                        getResources().getString(R.string.find_value_written_toast)
                                                + IMM_MID_ALERT_TEXT
                                                + getResources().getString(R.string.find_value_success_toast),
                                        Toast.LENGTH_SHORT).show();
                            }
                            if (parent.getItemAtPosition(position).toString().equalsIgnoreCase("High Alert")) {
                                byte[] convertedBytes = convertingTobyteArray(IMM_HIGH_ALERT);
                                BluetoothLeService.writeCharacteristicNoresponse(gattCharacteristic,
                                        convertedBytes);
                                Toast.makeText(getActivity(),
                                        getResources().getString(R.string.find_value_written_toast)
                                                + IMM_HIGH_ALERT_TEXT
                                                + getResources().getString(R.string.find_value_success_toast),
                                        Toast.LENGTH_SHORT).show();
                            }

                        }

                        @Override
                        public void onNothingSelected(AdapterView<?> parent) {
                            // TODO Auto-generated method stub

                        }
                    });
                }

            }
            if (uuidchara.equalsIgnoreCase(GattAttributes.TRANSMISSION_POWER_LEVEL)) {
                tp_layout.setVisibility(View.VISIBLE);
                tpr_layout.setVisibility(View.VISIBLE);
                mReadCharacteristic_tp = gattCharacteristic;
                mTransmissionPower = (ImageView) rootView.findViewById(R.id.findme_tx_power_img);
                mTransmissionPowerValue = (TextView) rootView.findViewById(R.id.findme_tx_power_txt);
                if (mReadCharacteristic_tp != null) {
                    prepareBroadcastDataReadtp(mReadCharacteristic_tp);
                }

            }

        }
    }

}