Example usage for android.widget LinearLayout getContext

List of usage examples for android.widget LinearLayout getContext

Introduction

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

Prototype

@ViewDebug.CapturedViewProperty
public final Context getContext() 

Source Link

Document

Returns the context the view is running in, through which it can access the current theme, resources, etc.

Usage

From source file:com.team3.classical.slidingtabs.SlidingTabsBasicFragment.java

void setClass(LinearLayout ll, String title, String place, String last, String time, int classes, int color) {
    View view = LayoutInflater.from(ll.getContext()).inflate(R.layout.item2, null);
    view.setMinimumHeight(dip2px(ll.getContext(), classes * 25));
    view.setBackgroundColor(colors[color]);
    ((TextView) view.findViewById(R.id.title)).setText(title);
    ((TextView) view.findViewById(R.id.place)).setText(place);
    ((TextView) view.findViewById(R.id.last)).setText(last);
    ((TextView) view.findViewById(R.id.time)).setText(time);

    view.setOnClickListener(new OnClickClassListener());
    ll.addView(view);/*from w  ww  . j  a v a2s .  co  m*/
}

From source file:com.hacktx.android.activities.EventDetailActivity.java

private void setupSpeakers() {
    LinearLayout speakersContainer = (LinearLayout) findViewById(R.id.speakerHolderLayout);
    ArrayList<ScheduleSpeaker> speakers = event.getSpeakerList();
    speakersContainer.removeAllViews();//from   w w w .j av a  2  s  .co  m

    if (speakers.size() == 0) {
        View speakerTitle = findViewById(R.id.speakersTitle);
        speakerTitle.setVisibility(View.GONE);
    }

    for (int child = 0; child < speakers.size(); child++) {
        final ScheduleSpeaker speaker = speakers.get(child);
        View childView = LayoutInflater.from(speakersContainer.getContext())
                .inflate(R.layout.event_detail_speaker, speakersContainer, false);

        CircularImageView speakerIcon = (CircularImageView) childView.findViewById(R.id.speakerIcon);
        Picasso.with(this).load(speaker.getImageUrl()).resize(150, 150).centerCrop()
                .placeholder(R.drawable.ic_profile).into(speakerIcon);
        ((TextView) childView.findViewById(R.id.speakerTitle))
                .setText(speaker.getName() + " | " + speaker.getOrganization());
        ((TextView) childView.findViewById(R.id.speakerDescription)).setText(speaker.getDescription());

        speakersContainer.addView(childView);
    }
}

From source file:com.hughes.android.dictionary.DictionaryManagerActivity.java

private View createDictionaryRow(final DictionaryInfo dictionaryInfo, final ViewGroup parent,
        boolean canLaunch) {

    View row = LayoutInflater.from(parent.getContext()).inflate(R.layout.dictionary_manager_row, parent, false);
    final TextView name = (TextView) row.findViewById(R.id.dictionaryName);
    final TextView details = (TextView) row.findViewById(R.id.dictionaryDetails);
    name.setText(application.getDictionaryName(dictionaryInfo.uncompressedFilename));

    final boolean updateAvailable = application.updateAvailable(dictionaryInfo);
    final Button downloadButton = (Button) row.findViewById(R.id.downloadButton);
    final DictionaryInfo downloadable = application.getDownloadable(dictionaryInfo.uncompressedFilename);
    boolean broken = false;
    if (!dictionaryInfo.isValid()) {
        broken = true;//from w  w  w.  j  ava  2s  .c om
        canLaunch = false;
    }
    if (downloadable != null && (!canLaunch || updateAvailable)) {
        downloadButton.setText(getString(R.string.downloadButton, downloadable.zipBytes / 1024.0 / 1024.0));
        downloadButton.setMinWidth(application.languageButtonPixels * 3 / 2);
        downloadButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                downloadDictionary(downloadable.downloadUrl, downloadable.zipBytes, downloadButton);
            }
        });
    } else {
        downloadButton.setVisibility(View.INVISIBLE);
    }

    LinearLayout buttons = (LinearLayout) row.findViewById(R.id.dictionaryLauncherButtons);
    final List<IndexInfo> sortedIndexInfos = application.sortedIndexInfos(dictionaryInfo.indexInfos);
    final StringBuilder builder = new StringBuilder();
    if (updateAvailable) {
        builder.append(getString(R.string.updateAvailable));
    }
    for (IndexInfo indexInfo : sortedIndexInfos) {
        final View button = application.createButton(buttons.getContext(), dictionaryInfo, indexInfo);
        buttons.addView(button);

        if (canLaunch) {
            button.setOnClickListener(new IntentLauncher(buttons.getContext(),
                    DictionaryActivity.getLaunchIntent(getApplicationContext(),
                            application.getPath(dictionaryInfo.uncompressedFilename), indexInfo.shortName,
                            "")));

        } else {
            button.setEnabled(false);
            button.setFocusable(false);
        }
        if (builder.length() != 0) {
            builder.append("; ");
        }
        builder.append(getString(R.string.indexInfo, indexInfo.shortName, indexInfo.mainTokenCount));
    }
    builder.append("; ");
    builder.append(getString(R.string.downloadButton, dictionaryInfo.uncompressedBytes / 1024.0 / 1024.0));
    if (broken) {
        name.setText("Broken: " + application.getDictionaryName(dictionaryInfo.uncompressedFilename));
        builder.append("; Cannot be used, redownload, check hardware/file system");
        // Allow deleting, but cannot open
        row.setLongClickable(true);
    }
    details.setText(builder.toString());

    if (canLaunch) {
        row.setClickable(true);
        row.setOnClickListener(new IntentLauncher(parent.getContext(),
                DictionaryActivity.getLaunchIntent(getApplicationContext(),
                        application.getPath(dictionaryInfo.uncompressedFilename),
                        dictionaryInfo.indexInfos.get(0).shortName, "")));
        // do not setFocusable, for keyboard navigation
        // offering only the index buttons is better.
        row.setLongClickable(true);
    }
    row.setBackgroundResource(android.R.drawable.menuitem_background);

    return row;
}

From source file:com.bytestemplar.tonedef.international.ButtonsFragment.java

public void updateButtons(int position) {
    LinearLayout ll_btn_container = (LinearLayout) getView().findViewById(R.id.buttons_container);

    if (ll_btn_container != null) {

        _current_position = position;/* ww  w .  j  a  v a2 s  . c  o  m*/
        CountryTones current_tones = CountryTonesRepository.getInstance().getCountryAtPosition(position);

        ll_btn_container.removeAllViewsInLayout();

        // Update label
        TextView tv_name = (TextView) getView().findViewById(R.id.tv_countryname);
        tv_name.setText(current_tones.getName());
        tv_name.setTypeface(UICustom.getInstance().getTypeface());
        if (current_tones.getFlagDrawable() > 0) {
            tv_name.setCompoundDrawablesWithIntrinsicBounds(current_tones.getFlagDrawable(), 0, 0, 0);
        }

        // Generate buttons
        HashMap<String, ToneSequence> sequences = current_tones.getSequences();

        for (Object o : sequences.entrySet()) {
            Map.Entry pair = (Map.Entry) o;

            String sequence_name = (String) pair.getKey();
            final ToneSequence sequence = (ToneSequence) pair.getValue();

            Button btn = new Button(ll_btn_container.getContext());
            btn.setText(sequence_name);
            btn.setTypeface(UICustom.getInstance().getTypeface());
            btn.setBackgroundResource(R.drawable.touchpadbutton);
            btn.setTextColor(Color.WHITE);
            btn.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    switch (event.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        sequence.start();
                        v.setBackgroundResource(R.drawable.touchpadbutton_selected);
                        break;
                    case MotionEvent.ACTION_UP:
                    case MotionEvent.ACTION_CANCEL:
                        sequence.stop();
                        v.setBackgroundResource(R.drawable.touchpadbutton);
                        break;
                    }
                    return false;
                }
            });
            btn.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT));
            ll_btn_container.addView(btn);
        }
    }
}

From source file:com.sim2dial.dialer.InCallActivity.java

private void displayOrHideContactPicture(LinearLayout callView, Uri pictureUri, boolean hide) {
    ImageView contactPicture = (ImageView) callView.findViewById(R.id.contactPicture);
    if (pictureUri != null) {
        LinphoneUtils.setImagePictureFromUri(callView.getContext(), contactPicture,
                Uri.parse(pictureUri.toString()), R.drawable.ic_contact);
    }/* w ww .jav a  2 s  .  c o m*/
    callView.setVisibility(hide ? View.GONE : View.VISIBLE);
}

From source file:org.linphone.InCallActivity.java

private void displayCall(Resources resources, LinphoneCall call, int index) {
    String sipUri = call.getRemoteAddress().asStringUriOnly();
    LinphoneAddress lAddress;/*  www .jav  a 2  s .  co m*/
    try {
        lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
    } catch (LinphoneCoreException e) {
        Log.e("Incall activity cannot parse remote address", e);
        lAddress = LinphoneCoreFactory.instance().createLinphoneAddress("uknown", "unknown", "unkonown");
    }

    // Control Row
    LinearLayout callView = (LinearLayout) inflater.inflate(R.layout.active_call_control_row, container, false);
    callView.setId(index + 1);
    setContactName(callView, lAddress, sipUri, resources);
    displayCallStatusIconAndReturnCallPaused(callView, call);
    setRowBackground(callView, index);
    registerCallDurationTimer(callView, call);
    callsList.addView(callView);

    // Image Row
    LinearLayout imageView = (LinearLayout) inflater.inflate(R.layout.active_call_image_row, container, false);
    Contact contact = ContactsManager.getInstance()
            .findContactWithAddress(imageView.getContext().getContentResolver(), lAddress);
    if (contact != null) {
        displayOrHideContactPicture(imageView, contact.getPhotoUri(), contact.getThumbnailUri(), false);
    } else {
        displayOrHideContactPicture(imageView, null, null, false);
    }
    callsList.addView(imageView);

    callView.setTag(imageView);
    callView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (v.getTag() != null) {
                View imageView = (View) v.getTag();
                if (imageView.getVisibility() == View.VISIBLE)
                    imageView.setVisibility(View.GONE);
                else
                    imageView.setVisibility(View.VISIBLE);
                callsList.invalidate();
            }
        }
    });
}

From source file:org.xingjitong.InCallActivity.java

private void displayCall(Resources resources, LinphoneCall call, int index) {
    String sipUri = call.getRemoteAddress().asStringUriOnly();
    LinphoneAddress lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
    // Control Row
    LinearLayout callView = (LinearLayout) inflater.inflate(R.layout.active_call_control_row, container, false);
    setContactPhone(callView, lAddress, sipUri, resources);
    //yyppcallingfun del
    //displayCallStatusIconAndReturnCallPaused(callView, call);
    setRowBackground(callView, index);//www.  j a va  2 s.  c  om
    registerCallDurationTimer(callView, call);
    callsList.addView(callView);

    // Image Row
    LinearLayout imageView = (LinearLayout) inflater.inflate(R.layout.active_call_image_row, container, false);
    Uri pictureUri = LinphoneUtils.findUriPictureOfContactAndSetDisplayName(lAddress,
            imageView.getContext().getContentResolver());

    final TextView name = (TextView) imageView.findViewById(R.id.call_name);
    //yyppcalling //yyppcallingui add
    //callhint = (TextView) imageView.findViewById(R.id.incall_callhint);

    phone = sipUri.substring(sipUri.indexOf(":") + 1, sipUri.indexOf("@"));
    if (phone.startsWith("01") && !phone.startsWith("010")) {
        phone = phone.substring(1);
    } else if (phone.startsWith("51201")) {
        phone = phone.substring(4);
    } else if (phone.startsWith("512")) {
        phone = phone.substring(3);
    }
    if (!phone.startsWith("1") && !phone.startsWith("0")) {
        phone = "0" + phone;
    }
    handler.post(new Runnable() {

        @Override
        public void run() {
            String n = ContactDB.Instance().getName(phone);
            if (!n.equals(phone) && n != null) {
                name.invalidate();
                name.setText(n);
            }
        }
    });
    displayOrHideContactPicture(imageView, pictureUri, false);
    callsList.addView(imageView);

    callView.setTag(imageView);
    callView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (v.getTag() != null) {
                View imageView = (View) v.getTag();
                if (imageView.getVisibility() == View.VISIBLE)
                    imageView.setVisibility(View.GONE);
                else
                    imageView.setVisibility(View.VISIBLE);
                callsList.invalidate();
            }
        }
    });
}

From source file:org.linphone.InCallActivity.java

private void displayOrHideContactPicture(LinearLayout callView, Uri pictureUri, Uri thumbnailUri,
        boolean hide) {
    AvatarWithShadow contactPicture = (AvatarWithShadow) callView.findViewById(R.id.contactPicture);
    if (pictureUri != null) {
        LinphoneUtils.setImagePictureFromUri(callView.getContext(), contactPicture.getView(),
                Uri.parse(pictureUri.toString()), thumbnailUri, R.drawable.unknown_small);
    }//from   w  ww.j  a  v a2s .  c  om
    callView.setVisibility(hide ? View.GONE : View.VISIBLE);
}

From source file:org.linphone.InCallActivity.java

private void setContactName(LinearLayout callView, LinphoneAddress lAddress, String sipUri,
        Resources resources) {//from  w  w w  .j  a v a2s  .  c  om
    TextView contact = (TextView) callView.findViewById(R.id.contactNameOrNumber);

    Contact lContact = ContactsManager.getInstance()
            .findContactWithAddress(callView.getContext().getContentResolver(), lAddress);
    if (lContact == null) {
        if (resources.getBoolean(R.bool.only_display_username_if_unknown)
                && LinphoneUtils.isSipAddress(sipUri)) {
            contact.setText(lAddress.getUserName());
        } else {
            contact.setText(sipUri);
        }
    } else {
        contact.setText(lContact.getName());
    }
}

From source file:org.xingjitong.InCallActivity.java

private void displayOrHideContactPicture(LinearLayout callView, Uri pictureUri, boolean hide) {
    //yyppcallingui  AvatarWithShadow-AvatarWithShadowcalling
    AvatarWithShadowcalling contactPicture = (AvatarWithShadowcalling) callView
            .findViewById(R.id.contactPicture);
    if (pictureUri != null) {
        LinphoneUtils.setImagePictureFromUri(callView.getContext(), contactPicture.getView(),
                Uri.parse(pictureUri.toString()), R.drawable.unknown_small); //callingcontact  //unknown_small//yyppcallingui
    }/*ww  w  .  java2 s.  c  o  m*/
    callView.setVisibility(hide ? View.GONE : View.VISIBLE);
}