Example usage for android.widget LinearLayout getChildCount

List of usage examples for android.widget LinearLayout getChildCount

Introduction

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

Prototype

public int getChildCount() 

Source Link

Document

Returns the number of children in the group.

Usage

From source file:org.linphone.ContactEditorFragment.java

private LinearLayout initSipAddressFields(final Contact contact) {
    LinearLayout controls = (LinearLayout) view.findViewById(R.id.controls_sip_address);
    controls.removeAllViews();/*from  ww  w .  j a  v  a  2s .c om*/

    if (contact != null) {
        for (String numberOrAddress : contact.getNumbersOrAddresses()) {
            boolean isSip = LinphoneUtils.isStrictSipAddress(numberOrAddress)
                    || !LinphoneUtils.isNumberAddress(numberOrAddress);
            if (isSip) {
                View view = displayNumberOrAddress(controls, numberOrAddress);
                if (view != null)
                    controls.addView(view);
            }
        }
    }

    if (newSipOrNumberToAdd != null) {
        boolean isSip = LinphoneUtils.isStrictSipAddress(newSipOrNumberToAdd)
                || !LinphoneUtils.isNumberAddress(newSipOrNumberToAdd);
        if (isSip) {
            View view = displayNumberOrAddress(controls, newSipOrNumberToAdd);
            if (view != null)
                controls.addView(view);
        }
    }

    if (controls.getChildCount() == 0) {
        addEmptyRowToAllowNewNumberOrAddress(controls, true);
    }

    return controls;
}

From source file:com.sdspikes.fireworks.FireworksActivity.java

private void displayInitialState() {
    switchToScreen(R.id.screen_game);/*  w w  w . j  a  v a  2s . c om*/
    GameState.HandNode currentNode = mTurnData.state.hands.get(mMyId);
    FragmentManager fm = getFragmentManager();
    fragments = new HashMap<>();

    if (fm.findFragmentById(R.id.my_hand) == null) {
        if (currentNode != null) {
            addHandFragment(fm, currentNode, mMyId, mIdToName.get(mMyId), R.id.my_hand);
        } else {
            Log.d(TAG, mMyId);
        }
    }

    if (fm.findFragmentById(R.id.other_hands) == null) {
        while (true) {
            String currentId = currentNode.nextPlayerId;
            if (currentId.equals(mMyId)) {
                break;
            }
            currentNode = mTurnData.state.hands.get(currentId);
            addHandFragment(fm, currentNode, currentId, mIdToName.get(currentId), R.id.other_hands);
        }
    }

    LinearLayout played = (LinearLayout) findViewById(R.id.played_pile);

    played.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            LinearLayout played = (LinearLayout) findViewById(R.id.played_pile);
            mDiscardWidthR2 = played.getMeasuredWidth();

            if (mDiscardWidthR2 != 0) {
                int usableWidth = mDiscardWidthR2 - findViewById(R.id.played_label).getMeasuredWidth();
                mDiscardWidthR1 = mDiscardWidthR2 - findViewById(R.id.discarded_label).getMeasuredWidth();
                for (int i = 1; i < played.getChildCount(); i++) {
                    ViewGroup.LayoutParams params = played.getChildAt(i).getLayoutParams();
                    params.width = usableWidth / 5;
                    played.getChildAt(i).setLayoutParams(params);
                }
                played.getViewTreeObserver().removeOnGlobalLayoutListener(this);

                LinearLayout chooseAttribute = (LinearLayout) findViewById(R.id.chooseAttribute);
                for (int i = 1; i <= 5; i++) {
                    chooseAttribute.addView(makeAttributeTextView(i, null));
                }
                for (GameState.CardColor color : GameState.CardColor.values()) {
                    chooseAttribute.addView(makeAttributeTextView(-1, color));
                }

                // In case all the data is ready already and was just waiting on this.
                updateDisplay();
            }
        }
    });

    createInitialLog();
    ((TextView) findViewById(R.id.log)).setMovementMethod(new ScrollingMovementMethod());
}

From source file:com.mdlive.sav.MDLiveProviderDetails.java

private void phsOnlyForPhone() {
    saveAppmtType("phone");
    byvideoBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
    byvideoBtn.setTextColor(getResources().getColor(R.color.disableBtn));
    ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_gray);
    byvideoBtnLayout.setVisibility(View.VISIBLE);
    byvideoBtnLayout.setClickable(false);
    byphoneBtnLayout.setVisibility(View.VISIBLE);
    byphoneBtnLayout.setOnClickListener(new View.OnClickListener() {
        @Override/*from ww  w  .j a  va2s .  com*/
        public void onClick(View v) {
            try {
                horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                byphoneBtnLayout.setBackgroundResource(R.drawable.searchpvr_blue_rounded_corner);
                byphoneBtn.setTextColor(Color.WHITE);
                ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon_white);
                ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_gray);
                horizontalscrollview.setVisibility(View.VISIBLE);
                byvideoBtnLayout.setVisibility(View.VISIBLE);
                byvideoBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
                byvideoBtn.setTextColor(getResources().getColor(R.color.disableBtn));
                byvideoBtnLayout.setClickable(false);

                LinearLayout layout = (LinearLayout) findViewById(R.id.panelMessageFiles);
                if (layout.getChildCount() > 0) {
                    layout.removeAllViews();
                }
                for (TextView tv : phoneList) {
                    layout.addView(tv);
                }
                saveConsultationType("Phone", MDLiveProviderDetails.this);
                //Enable Request Appointment Button
                enableReqAppmtBtn();
                horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon_white);
                selectedTimeslot = false;
                enableReqAppmtBtn();
                clearTimeSlotViews();
                horizontalscrollview.startAnimation(
                        AnimationUtils.loadAnimation(MDLiveProviderDetails.this, R.anim.mdlive_trans_left_in));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:com.mdlive.sav.MDLiveProviderDetails.java

private void onlyForIdaho() {
    byphoneBtnLayout.setVisibility(View.VISIBLE);
    byphoneBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
    byphoneBtn.setTextColor(getResources().getColor(R.color.disableBtn));
    ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon_gray);
    byphoneBtnLayout.setClickable(false);
    saveAppmtType("video");
    byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_white_rounded_corner);
    byvideoBtn.setTextColor(Color.GRAY);
    byvideoBtn.setTextColor(Color.GRAY);
    byvideoBtnLayout.setVisibility(View.VISIBLE);
    byvideoBtnLayout.setOnClickListener(new View.OnClickListener() {
        @Override/*from   w  ww . j ava 2 s .  c  om*/
        public void onClick(View v) {
            try {
                horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_blue_rounded_corner);
                byvideoBtn.setTextColor(Color.WHITE);
                ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_white);
                ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon_gray);
                byphoneBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
                byphoneBtn.setTextColor(getResources().getColor(R.color.disableBtn));
                byphoneBtnLayout.setVisibility(View.VISIBLE);
                byphoneBtnLayout.setClickable(false);

                horizontalscrollview.setVisibility(View.VISIBLE);
                LinearLayout layout = (LinearLayout) findViewById(R.id.panelMessageFiles);
                if (layout.getChildCount() > 0) {
                    layout.removeAllViews();
                }

                for (TextView tv : videoList) {
                    layout.addView(tv);
                }
                saveConsultationType("Video", MDLiveProviderDetails.this);
                //Enable Request Appointment Button

                horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_white);
                selectedTimeslot = false;
                enableReqAppmtBtn();
                clearTimeSlotViews();
                horizontalscrollview.startAnimation(
                        AnimationUtils.loadAnimation(MDLiveProviderDetails.this, R.anim.mdlive_trans_left_in));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:com.example.drugsformarinemammals.General_Info_Drug.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.general_info_drug);
    isStoredInLocal = false;// w w w  . j a  v  a 2s .co  m
    fiveLastScreen = false;
    helper = new Handler_Sqlite(this);
    helper.open();
    Bundle extras1 = this.getIntent().getExtras();
    if (extras1 != null) {
        infoBundle = extras1.getStringArrayList("generalInfoDrug");
        fiveLastScreen = extras1.getBoolean("fiveLastScreen");
        if (infoBundle == null)
            isStoredInLocal = true;
        if (!isStoredInLocal) {
            initializeGeneralInfoDrug();
            initializeCodesInformation();
            initializeCodes();
        } else {
            drug_name = extras1.getString("drugName");
            codes = helper.getCodes(drug_name);
            codesInformation = helper.getCodesInformation(drug_name);
        }
        //Title
        TextView drugTitle = (TextView) findViewById(R.id.drugTitle);
        drugTitle.setText(drug_name);
        drugTitle.setTypeface(Typeface.SANS_SERIF);

        //Description 
        LinearLayout borderDescription = new LinearLayout(this);
        borderDescription.setOrientation(LinearLayout.VERTICAL);
        borderDescription
                .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        borderDescription.setBackgroundResource(R.drawable.layout_border);

        TextView description = new TextView(this);
        if (isStoredInLocal)
            description.setText(helper.getDescription(drug_name));
        else
            description.setText(this.description);
        description.setTextSize(18);
        description.setTypeface(Typeface.SANS_SERIF);

        LinearLayout.LayoutParams paramsDescription = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsDescription.leftMargin = 60;
        paramsDescription.rightMargin = 60;
        paramsDescription.topMargin = 20;

        borderDescription.addView(description, borderDescription.getChildCount(), paramsDescription);

        LinearLayout layoutDescription = (LinearLayout) findViewById(R.id.layoutDescription);
        layoutDescription.addView(borderDescription, layoutDescription.getChildCount());

        //Animals
        TextView headerAnimals = (TextView) findViewById(R.id.headerAnimals);
        headerAnimals.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        Button cetaceansButton = (Button) findViewById(R.id.cetaceansButton);
        cetaceansButton.setText("CETACEANS");
        cetaceansButton.setTypeface(Typeface.SANS_SERIF);
        cetaceansButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                showDoseInformation(drug_name, "Cetaceans");
            }
        });

        Button pinnipedsButton = (Button) findViewById(R.id.pinnipedsButton);
        pinnipedsButton.setText("PINNIPEDS");
        pinnipedsButton.setTypeface(Typeface.SANS_SERIF);
        pinnipedsButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                SQLiteDatabase db = helper.open();
                ArrayList<String> families = new ArrayList<String>();
                if (db != null)
                    families = helper.read_animals_family(drug_name, "Pinnipeds");
                if ((families != null && families.size() == 1 && families.get(0).equals(""))
                        || (families != null && families.size() == 0))
                    showDoseInformation(drug_name, "Pinnipeds");
                else
                    showDoseInformationPinnipeds(drug_name, families);
            }
        });

        Button otherButton = (Button) findViewById(R.id.otherButton);
        otherButton.setText("OTHER MM");
        otherButton.setTypeface(Typeface.SANS_SERIF);
        otherButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                showDoseInformation(drug_name, "Other MM");
            }
        });

        //Codes & therapeutic target & anatomical target
        TextView headerATCvetCodes = (TextView) findViewById(R.id.headerATCvetCodes);
        headerATCvetCodes.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        //Action
        TextView headerActionAnatomical = (TextView) findViewById(R.id.headerActionAnatomical);
        headerActionAnatomical.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        createTextViewAnatomical();
        createBorderAnatomicalGroup();

        TextView headerActionTherapeutic = (TextView) findViewById(R.id.headerActionTherapeutic);
        headerActionTherapeutic.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        createTextViewTherapeutic();
        createBorderTherapeuticGroup();

        params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        params.leftMargin = 60;
        params.rightMargin = 60;
        params.topMargin = 20;

        Spinner codesSpinner = (Spinner) findViewById(R.id.codesSpinner);
        SpinnerAdapter adapterCodes = new SpinnerAdapter(this, R.layout.item_spinner, codes);
        adapterCodes.setDropDownViewResource(R.layout.spinner_dropdown_item);
        codesSpinner.setAdapter(adapterCodes);
        codesSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

            public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) {
                userEntryCode = parent.getSelectedItem().toString();
                int numCodes = codesInformation.size();

                layoutAnatomicalGroup.removeView(borderAnatomicalGroup);
                createBorderAnatomicalGroup();

                boolean founded = false;
                int i = 0;
                while (!founded && i < numCodes) {
                    if (userEntryCode.equals(codesInformation.get(i).getCode())) {
                        createTextViewAnatomical();
                        anatomicalGroup.setText(codesInformation.get(i).getAnatomic_group() + "\n");
                        borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(),
                                params);
                        founded = true;
                    }
                    i++;
                }

                layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical);
                layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount());
                layoutTherapeuticGroup.removeView(borderTherapeuticGroup);
                createBorderTherapeuticGroup();
                founded = false;
                i = 0;
                while (!founded && i < numCodes) {
                    if (userEntryCode.equals(codesInformation.get(i).getCode())) {
                        createTextViewTherapeutic();
                        therapeuticGroup.setText(codesInformation.get(i).getTherapeutic_group() + "\n");
                        borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(),
                                params);
                        founded = true;
                    }
                    i++;
                }
                layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic);
                layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount());
            }

            public void onNothingSelected(AdapterView<?> arg0) {
            }
        });

        layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical);
        layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic);

        borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(), params);
        borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(), params);

        layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount());
        layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount());

        //Generic Drug
        TextView headerGenericDrug = (TextView) findViewById(R.id.headerGenericDrug);
        headerGenericDrug.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
        boolean isAvalaible = false;
        if (isStoredInLocal)
            isAvalaible = helper.isAvalaible(drug_name);
        else
            isAvalaible = available.equals("Yes");
        if (isAvalaible) {
            ImageView genericDrug = new ImageView(this);
            genericDrug.setImageResource(R.drawable.tick_verde);
            LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug);
            layoutGenericDrug.addView(genericDrug);
        } else {
            Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf");
            TextView genericDrug = new TextView(this);
            genericDrug.setTypeface(font);
            genericDrug.setText("Nd");
            genericDrug.setTextColor(getResources().getColor(R.color.maroon));
            genericDrug.setTextSize(20);
            DisplayMetrics metrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(metrics);
            int size = metrics.widthPixels;
            int middle = size / 2;
            int quarter = size / 4;
            genericDrug.setTranslationX(middle - quarter);
            genericDrug.setTranslationY(-3);
            LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug);
            layoutGenericDrug.addView(genericDrug);
        }

        //Licenses
        TextView headerLicense = (TextView) findViewById(R.id.headerLicense);
        headerLicense.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        TextView fdaLicense = (TextView) findViewById(R.id.license1);
        Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf");
        fdaLicense.setTypeface(font);

        String fda;
        if (isStoredInLocal)
            fda = helper.getLicense_FDA(drug_name);
        else
            fda = license_FDA;
        if (fda.equals("Yes")) {
            fdaLicense.setText("Yes");
            fdaLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            fdaLicense.setText("Nd");
            fdaLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        TextView emaLicense = (TextView) findViewById(R.id.license3);
        emaLicense.setTypeface(font);
        String ema;
        if (isStoredInLocal)
            ema = helper.getLicense_EMA(drug_name);
        else
            ema = license_EMA;
        if (ema.equals("Yes")) {
            emaLicense.setText("Yes");
            emaLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            emaLicense.setText("Nd");
            emaLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        TextView aempsLicense = (TextView) findViewById(R.id.license2);
        aempsLicense.setTypeface(font);
        String aemps;
        if (isStoredInLocal)
            aemps = helper.getLicense_AEMPS(drug_name);
        else
            aemps = license_AEMPS;
        if (aemps.equals("Yes")) {
            aempsLicense.setText("Yes");
            aempsLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            aempsLicense.setText("Nd");
            aempsLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        ImageButton food_and_drug = (ImageButton) findViewById(R.id.food_and_drug);
        food_and_drug.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.fda.gov/animalveterinary/products/approvedanimaldrugproducts/default.htm"));
                startActivity(intent);
            }
        });

        ImageButton european_medicines_agency = (ImageButton) findViewById(R.id.european_medicines_agency);
        european_medicines_agency.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.ema.europa.eu/ema/index.jsp?curl=pages/medicines/landing/vet_epar_search.jsp&mid=WC0b01ac058001fa1c"));
                startActivity(intent);
            }
        });

        ImageButton logo_aemps = (ImageButton) findViewById(R.id.logo_aemps);
        logo_aemps.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.aemps.gob.es/medicamentosVeterinarios/Med-Vet-autorizados/home.htm"));
                startActivity(intent);
            }

        });

        if (helper.existDrug(drug_name)) {
            int drug_priority = helper.getDrugPriority(drug_name);
            ArrayList<String> sorted_drugs = new ArrayList<String>();
            sorted_drugs.add(0, drug_name);
            for (int i = 1; i < drug_priority; i++) {
                String name = helper.getDrugName(i);
                sorted_drugs.add(i, name);
            }

            for (int i = 0; i < sorted_drugs.size(); i++)
                helper.setDrugPriority(sorted_drugs.get(i), i + 1);
        }

        if (!isStoredInLocal) {
            //Server code
            String[] urls = { "http://formmulary.tk/Android/getDoseInformation.php?drug_name=",
                    "http://formmulary.tk/Android/getGeneralNotesInformation.php?drug_name=" };
            new GetDoseInformation(this).execute(urls);
        }

        helper.close();
    }

}

From source file:com.mobicage.rogerthat.plugins.messaging.ServiceMessageDetailActivity.java

private void addButton(final String senderName, String myEmail, boolean somebodyAnswered, boolean canEdit,
        TableLayout tableLayout, final ButtonTO button) {
    TableRow row = new TableRow(this);
    tableLayout.addView(row);// w w  w  .j a  v a2s  .  c o m
    row.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,
            TableLayout.LayoutParams.WRAP_CONTENT, 1));

    // XXX: inconsistent margin between 2 rows

    final Button buttonView = new Button(this);
    buttonView.setMinWidth(UIUtils.convertDipToPixels(this, 100));
    buttonView.setText(button.caption);
    buttonView.setTextColor(getResources().getColor(android.R.color.primary_text_dark));
    if (somebodyAnswered)
        buttonView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
    else {
        buttonView.setWidth(mDisplayWidth - UIUtils.convertDipToPixels(this, 12));
    }
    buttonView.setTextSize(19);
    row.addView(buttonView);

    final LinearLayout container = (LinearLayout) getLayoutInflater().inflate(R.layout.message_button_detail,
            null);
    container.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);

    boolean buttonSelectedByMe = false;
    for (MemberStatusTO status : mCurrentMessage.members) {
        if ((status.status & MessagingPlugin.STATUS_ACKED) == MessagingPlugin.STATUS_ACKED
                && ((button.id == null && status.button_id == null)
                        || (button.id != null && button.id.equals(status.button_id)))) {

            getLayoutInflater().inflate(R.layout.avatar, container);
            ImageView avatar = (ImageView) container.getChildAt(container.getChildCount() - 1);

            setAvatar(avatar, status.member);
            if (status.member.equals(myEmail))
                buttonSelectedByMe = true;

            int dp42 = UIUtils.convertDipToPixels(this, 42);
            int dp2 = UIUtils.convertDipToPixels(this, 1);
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) avatar.getLayoutParams();
            lp.setMargins(0, dp2, 0, 0);
            lp.width = dp42;
            lp.height = dp42;
        }
    }

    row.addView(container);

    boolean hasAction = button.action != null && !"".equals(button.action);
    final boolean buttonIsEnabled = canEdit
            && (mCurrentMessage.form != null || !buttonSelectedByMe || hasAction);
    buttonView.setEnabled(buttonIsEnabled);

    int color;
    if (button.id == null || mCurrentMessage.form != null && Message.POSITIVE.equals(button.id)) {
        color = buttonIsEnabled ? Message.GREEN_BUTTON_COLOR : Message.GREENGRAY_BUTTON_COLOR;
    } else if (mCurrentMessage.form != null && Message.NEGATIVE.equals(button.id)) {
        color = buttonIsEnabled ? Message.RED_BUTTON_COLOR : Message.REDGRAY_BUTTON_COLOR;
    } else {
        color = buttonIsEnabled ? Message.BLUE_BUTTON_COLOR : Message.BLUEGRAY_BUTTON_COLOR;
    }
    buttonView.getBackground().setColorFilter(color, PorterDuff.Mode.MULTIPLY);

    buttonView.setOnClickListener(new SafeViewOnClickListener() {

        @Override
        public void safeOnClick(View v) {
            T.UI();
            executeButtonClick(button, container, true);
        }
    });

    final HorizontalScrollView scroller = (HorizontalScrollView) findViewById(R.id.button_scroller);
    scroller.post(new SafeRunnable() {
        @Override
        protected void safeRun() throws Exception {
            scroller.fullScroll(ScrollView.FOCUS_RIGHT);
        }
    });
}

From source file:com.mdlive.sav.MDLiveProviderDetails.java

public void handleDateResponse(JSONObject response) {
    horizontalscrollview.setVisibility(View.GONE);
    //Fetch Data From the Services
    JsonParser parser = new JsonParser();
    JsonObject responObj = (JsonObject) parser.parse(response.toString());
    JsonObject profileobj = responObj.get("doctor_profile").getAsJsonObject();

    JsonObject appointment_slot = profileobj.get("appointment_slot").getAsJsonObject();
    JsonArray available_hour = appointment_slot.get("available_hour").getAsJsonArray();

    LinearLayout layout = (LinearLayout) findViewById(R.id.panelMessageFiles);
    String str_timeslot = "", str_phys_avail_id = "";
    if (layout.getChildCount() > 0) {
        layout.removeAllViews();//from   ww  w  . java 2s .  c  om
    }
    timeSlotListMap.clear();

    for (int i = 0; i < available_hour.size(); i++) {
        JsonObject availabilityStatus = available_hour.get(i).getAsJsonObject();
        String str_availabilityStatus = "";

        if (MdliveUtils.checkJSONResponseHasString(availabilityStatus, "status")) {
            str_availabilityStatus = availabilityStatus.get("status").getAsString();
            if (str_availabilityStatus.equals("Available")) {
                //This visibility is for future timeslots response for the corresponding date selection.
                //if  the future date has timeslots then make an appointment req layout nd textview visibility will be gone

                findViewById(R.id.noappmtsTxtLayout).setVisibility(View.GONE);
                reqfutureapptBtnLayout.setVisibility(View.GONE);
                JsonArray timeSlotArray = availabilityStatus.get("time_slot").getAsJsonArray();

                for (int j = 0; j < timeSlotArray.size(); j++) {
                    JsonObject timeSlotObj = timeSlotArray.get(j).getAsJsonObject();

                    if (MdliveUtils.checkJSONResponseHasString(timeSlotObj, "appointment_type")
                            && MdliveUtils.checkJSONResponseHasString(timeSlotObj, "timeslot")) {
                        str_appointmenttype = timeSlotObj.get("appointment_type").getAsString();
                        str_timeslot = timeSlotObj.get("timeslot").getAsString();
                        selectedTimestamp = timeSlotObj.get("timeslot").getAsString();

                        if (MdliveUtils.checkJSONResponseHasString(timeSlotObj, "phys_availability_id")) {
                            str_phys_avail_id = timeSlotObj.get("phys_availability_id").getAsString();
                        } else {
                            str_phys_avail_id = null;
                        }

                        HashMap<String, String> datemap = new HashMap<String, String>();
                        datemap.put("timeslot", str_timeslot);
                        datemap.put("phys_id", str_phys_avail_id);
                        datemap.put("appointment_type", str_appointmenttype);
                        videophoneparentLl.setVisibility(View.VISIBLE);
                        timeSlotListMap.add(datemap);

                        final Button myText = new Button(MDLiveProviderDetails.this);

                        if (str_timeslot.equals("0")) {
                            final int density = (int) getBaseContext().getResources()
                                    .getDisplayMetrics().density;

                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                                myText.setElevation(0f);
                            }
                            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                                    LinearLayout.LayoutParams.WRAP_CONTENT,
                                    LinearLayout.LayoutParams.WRAP_CONTENT);
                            params.setMargins(4 * density, 4 * density, 4 * density, 4 * density);
                            myText.setLayoutParams(params);
                            myText.setGravity(Gravity.CENTER);
                            myText.setTextColor(Color.WHITE);
                            myText.setTextSize(16);
                            myText.setPadding(8 * density, 4 * density, 8 * density, 4 * density);
                            myText.setBackgroundResource(R.drawable.timeslot_white_rounded_corner);
                            myText.setText("Now");
                            myText.setBackgroundResource(R.drawable.timeslot_blue_rounded_corner);
                            myText.setClickable(true);
                            previousSelectedTv = myText;
                            if (str_appointmenttype.toLowerCase().contains("video")
                                    || str_appointmenttype.toLowerCase().contains("video or phone")) {
                                videoList.add(myText);
                            }
                            if (str_appointmenttype.toLowerCase().contains("phone")) {
                                phoneList.add(myText);
                            }

                            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                                    LinearLayout.LayoutParams.WRAP_CONTENT,
                                    LinearLayout.LayoutParams.WRAP_CONTENT);
                            lp.setMargins(4 * density, 4 * density, 4 * density, 4 * density);
                            myText.setLayoutParams(lp);
                            myText.setTag("Now");
                            defaultNowTextPreferences(myText, str_appointmenttype);
                            selectedTimeslot = true;
                            clickEventForHorizontalText(myText, str_timeslot, str_phys_avail_id);
                            layout.addView(myText);
                        } else {
                            setHorizontalScrollviewTimeslots(layout, str_timeslot, j, str_phys_avail_id);
                        }
                    }
                }
            } else {
                if (layout.getChildCount() == 0) {
                    selectedTimeslot = false;
                    findViewById(R.id.noappmtsTxtLayout).setVisibility(View.VISIBLE);
                    ((TextView) findViewById(R.id.noAppmtsTxt))
                            .setText(getString(R.string.mdl_notimeslots_txt));
                    reqfutureapptBtnLayout.setVisibility(viewsVisibility);
                    ((TextView) findViewById(R.id.reqfutureapptBtn)).setText("Make an appointment request");
                    ((TextView) findViewById(R.id.reqfutureapptBtn)).setTextColor(Color.parseColor("#0079FD"));
                    videophoneparentLl.setVisibility(View.GONE);
                    tapReqFutureBtnAction();
                    findViewById(R.id.reqApmtBtm).setVisibility(View.GONE);
                }
            }
        }
    }

}

From source file:fiskinfoo.no.sintef.fiskinfoo.MapFragment.java

private void createMapLayerSelectionDialog() {
    if (layersAndVisibility == null) {
        getLayersAndVisibility();//ww w  .j  a va 2  s.  c o m
    }

    final Dialog dialog = dialogInterface.getDialog(getActivity(), R.layout.dialog_select_map_layers,
            R.string.choose_map_layers);
    Button okButton = (Button) dialog.findViewById(R.id.select_map_layers_update_map_button);
    final List<CheckBoxRow> rows = new ArrayList<>();
    final LinearLayout mapLayerLayout = (LinearLayout) dialog.findViewById(R.id.map_layers_checkbox_layout);
    final Button cancelButton = (Button) dialog.findViewById(R.id.select_map_layers_cancel_button);
    LayerAndVisibility[] layers = new Gson().fromJson(layersAndVisibility.toString(),
            LayerAndVisibility[].class);
    for (LayerAndVisibility layer : layers) {
        if (layer.name.equals("Grunnkart") || layer.name.contains("OpenLayers_Control")) {
            continue;
        }
        boolean isActive;
        isActive = layer.isVisible;

        CheckBoxRow row = rowsInterface.getCheckBoxRow(getActivity(), layer.name, false, isActive);
        rows.add(row);
        View mapLayerRow = row.getView();
        mapLayerLayout.addView(mapLayerRow);
    }

    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            List<String> layersList = new ArrayList<>();
            layersList.add("Grunnkart");

            for (int i = 0; i < mapLayerLayout.getChildCount(); i++) {
                if (rows.get(i).isChecked()) {
                    layersList.add(rows.get(i).getText());
                }
            }

            user.setActiveLayers(layersList);
            user.writeToSharedPref(getActivity());
            dialog.dismiss();

            if (layersList.contains(getString(R.string.fishing_facility_name))
                    && !user.getIsFishingFacilityAuthenticated()) {
                dialogInterface.getHyperlinkAlertDialog(getActivity(),
                        getString(R.string.about_fishing_facility_title),
                        getString(R.string.about_fishing_facility_details)).show();
            }

            JSONArray json = new JSONArray(layersList);
            browser.loadUrl("javascript:toggleLayers(" + json + ")");

            getLayersAndVisibility();
        }
    });

    cancelButton.setOnClickListener(onClickListenerInterface.getDismissDialogListener(dialog));

    dialog.show();
}

From source file:com.mdlive.sav.MDLiveProviderDetails.java

private void clickForVideoOrPhoneTapReqFutureAction() {
    findViewById(R.id.dateTxtLayout).setVisibility(View.VISIBLE);
    tapSeetheDoctorTxtLayout.setVisibility(View.GONE);
    reqfutureapptBtnLayout.setVisibility(View.GONE);
    videophoneparentLl.setVisibility(View.VISIBLE);
    horizontalscrollview.setVisibility(View.GONE);
    //This condition is only for PHS Users

    final UserBasicInfo userBasicInfo = UserBasicInfo.readFromSharedPreference(getBaseContext());
    //PHS user// w ww. j  av  a  2  s . co m
    if (userBasicInfo.getPersonalInfo().getConsultMethod().equalsIgnoreCase("video")) {
        byphoneBtnLayout.setVisibility(View.INVISIBLE);
        byphoneBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
        byphoneBtn.setTextColor(getResources().getColor(R.color.disableBtn));
        ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon_gray);
        byphoneBtnLayout.setClickable(false);

        saveAppmtType("video");
        byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_white_rounded_corner);
        byvideoBtn.setTextColor(Color.GRAY);
        byvideoBtn.setTextColor(Color.GRAY);
        byvideoBtnLayout.setVisibility(View.VISIBLE);
        byvideoBtnLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                    byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_blue_rounded_corner);
                    byvideoBtn.setTextColor(Color.WHITE);
                    ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_white);
                    ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon_gray);
                    byphoneBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
                    byphoneBtn.setTextColor(getResources().getColor(R.color.disableBtn));
                    byphoneBtnLayout.setVisibility(View.INVISIBLE);
                    byphoneBtnLayout.setClickable(false);

                    horizontalscrollview.setVisibility(View.VISIBLE);
                    final LinearLayout layout = (LinearLayout) findViewById(R.id.panelMessageFiles);
                    if (layout.getChildCount() > 0) {
                        layout.removeAllViews();
                    }

                    for (TextView tv : videoList) {
                        layout.addView(tv);
                    }
                    saveConsultationType("Video", MDLiveProviderDetails.this);
                    //Enable Request Appointment Button
                    enableReqAppmtBtn();
                    ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_white);
                    //horizontalscrollview.smoothScrollTo(0,0);

                    horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                    horizontalscrollview.postDelayed(new Runnable() {
                        public void run() {
                            horizontalscrollview.fullScroll(HorizontalScrollView.FOCUS_LEFT);
                        }
                    }, 100L);
                    //horizontalscrollview.fullScroll(HorizontalScrollView.FOCUS_LEFT);
                    selectedTimeslot = false;
                    enableReqAppmtBtn();
                    clearTimeSlotViews();
                    horizontalscrollview.startAnimation(AnimationUtils.loadAnimation(MDLiveProviderDetails.this,
                            R.anim.mdlive_trans_left_in));

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

    } else if (userBasicInfo.getPersonalInfo().getConsultMethod().equalsIgnoreCase("phone")) {
        phsOnlyForPhone();
    }
    //Only For idaho
    else if (longLocation.equalsIgnoreCase("idaho")) {
        onlyForIdaho();
    }
    //Only For Texas
    else if (longLocation.equalsIgnoreCase("texas")) {
        phsOnlyForPhone();
    }
    //Vido or Phone Button on Click listener for Blue color
    else {
        //Disabling the Video or Phone Based on the Phone list and video list
        //if the phone list is empty we should not shown the Phone Layout
        //if the video list is empty then we should not show the Video Layout.
        byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_white_rounded_corner);
        ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon);
        ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon);
        byvideoBtn.setTextColor(Color.GRAY);
        byphoneBtnLayout.setBackgroundResource(R.drawable.searchpvr_white_rounded_corner);
        byphoneBtn.setTextColor(Color.GRAY);

        if (videoList.size() == 0) {
            saveAppmtType("phone");
            byvideoBtnLayout.setVisibility(View.VISIBLE);
            byvideoBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
            byvideoBtn.setTextColor(getResources().getColor(R.color.disableBtn));
            ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_gray);
            byvideoBtnLayout.setClickable(false);
        } else {
            byvideoBtnLayout.setVisibility(View.VISIBLE);
            byvideoBtnLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    try {
                        horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                        byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_blue_rounded_corner);
                        byvideoBtn.setTextColor(Color.WHITE);
                        ((ImageView) findViewById(R.id.videoicon))
                                .setImageResource(R.drawable.video_icon_white);
                        byphoneBtnLayout.setVisibility(View.VISIBLE);
                        byphoneBtnLayout.setBackgroundResource(R.drawable.searchpvr_white_rounded_corner);
                        byphoneBtn.setTextColor(Color.GRAY);
                        ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon);

                        horizontalscrollview.setVisibility(View.VISIBLE);
                        LinearLayout layout = (LinearLayout) findViewById(R.id.panelMessageFiles);
                        if (layout.getChildCount() > 0) {
                            layout.removeAllViews();
                        }

                        for (TextView tv : videoList) {
                            layout.addView(tv);
                        }
                        saveConsultationType("Video", MDLiveProviderDetails.this);
                        //Enable Request Appointment Button

                        horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                        ((ImageView) findViewById(R.id.videoicon))
                                .setImageResource(R.drawable.video_icon_white);
                        ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon);
                        selectedTimeslot = false;
                        enableReqAppmtBtn();
                        clearTimeSlotViews();
                        horizontalscrollview.startAnimation(AnimationUtils
                                .loadAnimation(MDLiveProviderDetails.this, R.anim.mdlive_trans_left_in));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }
        if (phoneList.size() == 0) {
            saveAppmtType("video");
            byphoneBtnLayout.setVisibility(View.VISIBLE);
            byphoneBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
            byphoneBtn.setTextColor(getResources().getColor(R.color.disableBtn));
            ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon_gray);
            byphoneBtnLayout.setClickable(false);
        } else {
            byphoneBtnLayout.setVisibility(View.VISIBLE);
            byphoneBtnLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    try {
                        horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                        byphoneBtnLayout.setBackgroundResource(R.drawable.searchpvr_blue_rounded_corner);
                        byphoneBtn.setTextColor(Color.WHITE);
                        ((ImageView) findViewById(R.id.phoneicon))
                                .setImageResource(R.drawable.phone_icon_white);

                        byvideoBtnLayout.setVisibility(View.VISIBLE);
                        byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_white_rounded_corner);
                        byvideoBtn.setTextColor(Color.GRAY);
                        ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_gray);
                        horizontalscrollview.setVisibility(View.VISIBLE);
                        LinearLayout layout = (LinearLayout) findViewById(R.id.panelMessageFiles);
                        if (layout.getChildCount() > 0) {
                            layout.removeAllViews();
                        }
                        for (TextView tv : phoneList) {
                            layout.addView(tv);
                        }
                        saveConsultationType("Phone", MDLiveProviderDetails.this);
                        //Enable Request Appointment Button

                        horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                        ((ImageView) findViewById(R.id.phoneicon))
                                .setImageResource(R.drawable.phone_icon_white);
                        ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon);
                        selectedTimeslot = false;
                        enableReqAppmtBtn();
                        clearTimeSlotViews();
                        horizontalscrollview.startAnimation(AnimationUtils
                                .loadAnimation(MDLiveProviderDetails.this, R.anim.mdlive_trans_left_in));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }

    }

}

From source file:com.google.android.gcm.demo.ui.InstanceIdFragment.java

@Override
public void refresh() {
    new AsyncTask<Void, Void, Void>() {
        @Override/*from  w  ww  . j a  va  2 s .co m*/
        protected Void doInBackground(Void... params) {
            final String instanceId = mInstanceIdHelper.getInstanceId();
            final String creationTime = DateFormat.getDateTimeInstance()
                    .format(new Date(mInstanceIdHelper.getCreationTime()));
            final Activity activity = getActivity();
            if (activity != null) {
                Handler handler = new Handler(activity.getMainLooper());
                handler.post(new Runnable() {
                    public void run() {
                        setValue(activity.findViewById(R.id.iid_instance_id), instanceId);
                        setValue(activity.findViewById(R.id.iid_creation_time), creationTime);
                    }
                });
            }
            return null;
        }
    }.execute();
    float density = getActivity().getResources().getDisplayMetrics().density;
    SimpleArrayMap<String, Sender> addressBook = mSenders.getSenders();
    LinearLayout sendersList = new LinearLayout(getActivity());
    sendersList.setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < addressBook.size(); i++) {
        Sender sender = addressBook.valueAt(i);
        if (sender.appTokens.size() > 0) {
            LinearLayout senderRow = (LinearLayout) getActivity().getLayoutInflater()
                    .inflate(R.layout.widget_icon_text_button_row, sendersList, false);
            ImageView senderIcon = (ImageView) senderRow.findViewById(R.id.widget_itbr_icon);
            TextView senderLabel = (TextView) senderRow.findViewById(R.id.widget_itbr_text);
            senderRow.findViewById(R.id.widget_itbr_button).setVisibility(View.GONE);
            senderIcon.setImageResource(R.drawable.cloud_googblue);
            senderIcon.setPadding(0, 0, (int) (8 * density), 0);
            senderLabel.setText(getString(R.string.topics_sender_id, sender.senderId));
            sendersList.addView(senderRow);
            for (Token token : sender.appTokens.values()) {
                LinearLayout row = (LinearLayout) getActivity().getLayoutInflater()
                        .inflate(R.layout.widget_icon_text_button_row, sendersList, false);
                ImageView icon = (ImageView) row.findViewById(R.id.widget_itbr_icon);
                TextView label = (TextView) row.findViewById(R.id.widget_itbr_text);
                Button button = (Button) row.findViewById(R.id.widget_itbr_button);
                icon.setImageResource(R.drawable.smartphone_grey600);
                label.setText(token.scope + " - " + AbstractFragment.truncateToMediumString(token.token));
                button.setText(R.string.iid_delete_token);
                button.setTag(R.id.tag_senderid, sender.senderId);
                button.setTag(R.id.tag_scope, token.scope);
                button.setOnClickListener(this);
                row.setPadding((int) (16 * density), 0, 0, 0);
                sendersList.addView(row);
            }
        }
    }
    if (sendersList.getChildCount() == 0) {
        TextView noTokens = new TextView(getActivity());
        noTokens.setText(getString(R.string.iid_no_tokens));
        noTokens.setTypeface(null, Typeface.ITALIC);
        sendersList.addView(noTokens);
    }
    FrameLayout tokensView = (FrameLayout) getActivity().findViewById(R.id.iid_tokens_wrapper);
    tokensView.removeAllViews();
    tokensView.addView(sendersList);
}