Example usage for android.view ViewGroup findViewById

List of usage examples for android.view ViewGroup findViewById

Introduction

In this page you can find the example usage for android.view ViewGroup findViewById.

Prototype

@Nullable
public final <T extends View> T findViewById(@IdRes int id) 

Source Link

Document

Finds the first descendant view with the given ID, the view itself if the ID matches #getId() , or null if the ID is invalid (< 0) or there is no matching view in the hierarchy.

Usage

From source file:ca.zadrox.dota2esportticker.ui.MatchDetailActivity.java

private View makeTeamView(Team team, ViewGroup root) {

    ViewGroup teamView = (ViewGroup) getLayoutInflater().inflate(R.layout.card_team, root, false);
    TextView teamName = (TextView) teamView.findViewById(R.id.card_team_name);
    BezelImageView teamLogo = (BezelImageView) teamView.findViewById(R.id.card_team_logo);
    ExpandableHeightGridView teamContent = (ExpandableHeightGridView) teamView
            .findViewById(R.id.card_team_gridview);

    final Uri teamUri = Uri.parse(team.teamUrl);
    (teamView.findViewById(R.id.card_team_link)).setOnClickListener(new View.OnClickListener() {
        @Override/*w w  w. j  a  v a2 s. co  m*/
        public void onClick(View v) {
            startActivity(new Intent(Intent.ACTION_VIEW, teamUri));
        }
    });

    TextView bettingOdds = (TextView) teamView.findViewById(R.id.card_team_gosubet);

    if (team.gosubetTie != null) {
        teamView.findViewById(R.id.card_team_gb_windraw).setVisibility(View.VISIBLE);
        bettingOdds.setText(team.gosubetWin + "\n" + team.gosubetTie);
    } else {
        bettingOdds.setText(team.gosubetWin);
    }

    if (team.recPerf != null) {
        RecentPerfAdapter mAdapter = new RecentPerfAdapter(this, R.layout.grid_recent_perf, team.recPerf);

        teamContent.setExpanded(true);
        teamName.setText(team.name);
        Picasso.with(this).load(team.flagUrl).into(teamLogo);
        teamContent.setAdapter(mAdapter);
        teamContent.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                RecentMatch match = (RecentMatch) parent.getAdapter().getItem(position);
                final Uri uri = Uri.parse(match.matchUrl);
                startActivity(new Intent(Intent.ACTION_VIEW, uri));
            }
        });

    } else if (team.players != null) {
        TextView contentDescriptor = (TextView) teamView.findViewById(R.id.card_team_content_descriptor);
        PlayerAdapter mAdapter = new PlayerAdapter(this, R.layout.grid_player, team.players);

        contentDescriptor.setText("Players:");
        teamContent.setExpanded(true);

        teamContent.setColumnWidth(Math.round(UIUtils.dpToPx(getResources().getDisplayMetrics(), 120f)));
        teamName.setText(team.name);
        Picasso.with(this).load(team.flagUrl).into(teamLogo);
        teamContent.setAdapter(mAdapter);

        teamContent.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Player mPlayer = (Player) parent.getAdapter().getItem(position);
                final Uri uri = Uri.parse(mPlayer.profilePageUrl);
                startActivity(new Intent(Intent.ACTION_VIEW, uri));
            }
        });
    }

    return teamView;
}

From source file:org.ale.openwatch.FeedFragmentActivity.java

private View inflateCustomTab(String tab_title) {
    ViewGroup tab = (ViewGroup) inflater.inflate(R.layout.tab_indicator_openwatch,
            (ViewGroup) this.findViewById(android.R.id.tabs), false);
    ((TextView) tab.findViewById(R.id.title)).setText(tab_title);
    return tab;//www  .  ja v  a  2 s .c  o  m
}

From source file:com.achep.base.ui.DialogBuilder.java

/**
 * Builds dialog's view/*w  w  w.  ja  v  a2  s.c o m*/
 *
 * @throws IllegalArgumentException when type is not one of defined.
 * @see #LAYOUT_COMMON
 * @see #LAYOUT_SKELETON
 */
public View createView(int type) {
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    ViewGroup rootLayout = (ViewGroup) createSkeleton();
    ViewGroup contentLayout = rootLayout;

    switch (type) {
    case LAYOUT_COMMON:
        final boolean hasMessageOnly = mView == null && mViewRes == 0;
        final int layoutResource = mContentViewRes != 0 ? mContentViewRes
                : hasMessageOnly ? R.layout.dialog_message : R.layout.dialog_content;

        ViewStub viewStub = (ViewStub) inflater.inflate(R.layout.dialog_main_body, rootLayout, true)
                .findViewById(R.id.placeholder);
        viewStub.setLayoutResource(layoutResource);

        contentLayout = (ViewGroup) viewStub.inflate().findViewById(R.id.content);
        if (contentLayout == null)
            contentLayout = rootLayout;
        TextView messageView = (TextView) contentLayout.findViewById(R.id.message);

        if (messageView != null) {
            if (!TextUtils.isEmpty(mMessageText)) {
                messageView.setMovementMethod(new LinkMovementMethod());
                messageView.setText(mMessageText);
            } else {
                ViewGroup vg = (ViewGroup) messageView.getParent();
                vg.removeView(messageView);
            }
        }

        // Fall down.
    case LAYOUT_SKELETON:

        if (mViewRes != 0) {
            inflater.inflate(mViewRes, contentLayout, true);
        } else if (mView != null) {
            contentLayout.addView(mView);
        }

        return rootLayout;
    default:
        throw new IllegalArgumentException();
    }
}

From source file:com.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.java

public void layoutAddToDictionaryHint(final String word, final ViewGroup addToDictionaryStrip) {
    final boolean shouldShowUiToAcceptTypedWord = Settings.getInstance()
            .getCurrent().mShouldShowUiToAcceptTypedWord;
    final int stripWidth = addToDictionaryStrip.getWidth();
    final int width = shouldShowUiToAcceptTypedWord ? stripWidth : stripWidth - mDividerWidth - mPadding * 2;

    final TextView wordView = (TextView) addToDictionaryStrip.findViewById(R.id.word_to_save);
    wordView.setTextColor(mColorTypedWord);
    final int wordWidth = (int) (width * mCenterSuggestionWeight);
    final CharSequence wordToSave = getEllipsizedText(word, wordWidth, wordView.getPaint());
    final float wordScaleX = wordView.getTextScaleX();
    wordView.setText(wordToSave);//w  ww.j a  v a  2 s .com
    wordView.setTextScaleX(wordScaleX);
    setLayoutWeight(wordView, mCenterSuggestionWeight, ViewGroup.LayoutParams.MATCH_PARENT);
    final int wordVisibility = shouldShowUiToAcceptTypedWord ? View.GONE : View.VISIBLE;
    wordView.setVisibility(wordVisibility);
    addToDictionaryStrip.findViewById(R.id.word_to_save_divider).setVisibility(wordVisibility);

    final Resources res = addToDictionaryStrip.getResources();
    final CharSequence hintText;
    final int hintWidth;
    final float hintWeight;
    final TextView hintView = (TextView) addToDictionaryStrip.findViewById(R.id.hint_add_to_dictionary);
    if (shouldShowUiToAcceptTypedWord) {
        hintText = res.getText(R.string.hint_add_to_dictionary_without_word);
        hintWidth = width;
        hintWeight = 1.0f;
        hintView.setGravity(Gravity.CENTER);
    } else {
        final boolean isRtlLanguage = (ViewCompat
                .getLayoutDirection(addToDictionaryStrip) == ViewCompat.LAYOUT_DIRECTION_RTL);
        final String arrow = isRtlLanguage ? RIGHTWARDS_ARROW : LEFTWARDS_ARROW;
        final boolean isRtlSystem = SubtypeLocaleUtils.isRtlLanguage(res.getConfiguration().locale);
        final CharSequence hint = res.getText(R.string.hint_add_to_dictionary);
        hintText = (isRtlLanguage == isRtlSystem) ? (arrow + hint) : (hint + arrow);
        hintWidth = width - wordWidth;
        hintWeight = 1.0f - mCenterSuggestionWeight;
        hintView.setGravity(Gravity.CENTER_VERTICAL | Gravity.START);
    }
    hintView.setTextColor(mColorAutoCorrect);
    final float hintScaleX = getTextScaleX(hintText, hintWidth, hintView.getPaint());
    hintView.setText(hintText);
    hintView.setTextScaleX(hintScaleX);
    setLayoutWeight(hintView, hintWeight, ViewGroup.LayoutParams.MATCH_PARENT);
}

From source file:com.filemanager.free.fragments.TabFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.tabfragment, container, false);
    fragmentManager = getActivity().getSupportFragmentManager();
    mToolBarContainer = getActivity().findViewById(R.id.lin);
    indicator = (Indicator) getActivity().findViewById(R.id.indicator);
    //indicator_ = (CirclePageIndicator ) getActivity().findViewById(R.id.indicator_);
    Sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
    savepaths = Sp.getBoolean("savepaths", true);
    int theme = Integer.parseInt(Sp.getString("theme", "0"));
    theme1 = theme == 2 ? PreferenceUtils.hourOfDay() : theme;
    mViewPager = (CustomViewPager) rootView.findViewById(R.id.pager);

    if (getArguments() != null) {
        path = getArguments().getString("path");
    }//from  www. j  av  a  2 s  .c o  m
    buttons = getActivity().findViewById(R.id.buttons);
    mainActivity = ((MainActivity) getActivity());
    mainActivity.supportInvalidateOptionsMenu();
    mViewPager.addOnPageChangeListener(this);

    mSectionsPagerAdapter = new ScreenSlidePagerAdapter(getActivity().getSupportFragmentManager());
    if (savedInstanceState == null) {
        int l = Sp.getInt("currenttab", 1);
        TabHandler tabHandler = new TabHandler(getActivity(), null, null, 1);
        List<Tab> tabs1 = tabHandler.getAllTabs();
        int i = tabs1.size();
        if (i == 0) {
            if (mainActivity.storage_count > 1)
                addTab(new Tab(1, "", ((EntryItem) DataUtils.list.get(1)).getPath(), "/"), 1, "");
            else
                addTab(new Tab(1, "", "/", "/"), 1, "");
            if (!DataUtils.list.get(0).isSection()) {
                String pa = ((EntryItem) DataUtils.list.get(0)).getPath();
                addTab(new Tab(2, "", pa, pa), 2, "");
            } else
                addTab(new Tab(2, "", ((EntryItem) DataUtils.list.get(1)).getPath(), "/"), 2, "");
        } else {
            if (path != null && path.length() != 0) {
                if (l == 1)
                    addTab(tabHandler.findTab(1), 1, "");
                addTab(tabHandler.findTab(l + 1), l + 1, path);
                if (l == 0)
                    addTab(tabHandler.findTab(2), 2, "");
            } else {
                addTab(tabHandler.findTab(1), 1, "");
                addTab(tabHandler.findTab(2), 2, "");
            }
        }

        mViewPager.setAdapter(mSectionsPagerAdapter);

        try {
            mViewPager.setCurrentItem(l, true);
        } catch (Exception e) {
            e.printStackTrace();
        }

    } else {
        fragments.clear();
        try {
            if (fragmentManager == null)
                fragmentManager = getActivity().getSupportFragmentManager();
            fragments.add(0, fragmentManager.getFragment(savedInstanceState, "tab" + 0));
            fragments.add(1, fragmentManager.getFragment(savedInstanceState, "tab" + 1));
        } catch (Exception e) {
            e.printStackTrace();
        }
        mSectionsPagerAdapter = new ScreenSlidePagerAdapter(getActivity().getSupportFragmentManager());

        mViewPager.setAdapter(mSectionsPagerAdapter);
        int pos1 = savedInstanceState.getInt("pos", 0);
        mViewPager.setCurrentItem(pos1);
        mSectionsPagerAdapter.notifyDataSetChanged();
    }

    indicator.setViewPager(mViewPager);

    mainActivity.mainFragment = (Main) getTab();

    return rootView;
}

From source file:com.musenkishi.wally.fragments.SearchFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) {
    final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_search, container, false);
    if (rootView != null) {
        super.onCreateView(rootView);
        quickReturnBackground = rootView.findViewById(R.id.quick_return_protective_background);
        quickReturnView = rootView.findViewById(R.id.quick_return_view);
        quickReturnEditTextClearButton = (ImageButton) rootView.findViewById(R.id.quick_return_edittext_clear);
        quickReturnEditTextClearButton.setOnClickListener(new View.OnClickListener() {
            @Override//from ww  w  .  java 2 s . co  m
            public void onClick(View v) {
                if (quickReturnEditText != null) {
                    query = "";
                    quickReturnEditText.setText("");
                    quickReturnEditText.performClick();
                    showKeyboard(quickReturnEditText);
                }
            }
        });
        quickReturnEditText = (EditText) rootView.findViewById(R.id.quick_return_edittext);
        quickReturnEditText.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                quickReturnEditText.setCursorVisible(true);
                quickReturnView.animate().translationY(0.0f).setDuration(300)
                        .setInterpolator(new EaseInOutBezierInterpolator()).start();
                quickReturnBackground.animate().translationY(0.0f).alpha(1.0f).setDuration(300)
                        .setInterpolator(new EaseInOutBezierInterpolator()).start();
            }
        });
        quickReturnEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                    return search();
                }
                return false;
            }

        });
        quickReturnEditText.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                if (!TextUtils.isEmpty(s)) {
                    quickReturnEditTextClearButton.setVisibility(View.VISIBLE);
                } else {
                    quickReturnEditTextClearButton.setVisibility(View.GONE);
                }
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });

        gridView.setOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);

                float currentTranslationY = quickReturnView.getTranslationY();
                float maxTranslationY = quickReturnHeight;
                float newTranslationY = currentTranslationY + -dy;

                if (newTranslationY > 0) {
                    newTranslationY = 0;
                } else if (newTranslationY < -maxTranslationY) {
                    newTranslationY = -maxTranslationY;
                }
                quickReturnView.setTranslationY(newTranslationY);

                float percent = (-maxTranslationY) / 100.0f;
                float currentPercent = 100 - (newTranslationY / percent);

                quickReturnBackground.setAlpha(currentPercent / 100);
                quickReturnBackground.setTranslationY(newTranslationY);

            }
        });

        colorPickerButton = rootView.findViewById(R.id.quick_return_color_picker);
        colorPickerButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showColorPickerDialog();

            }
        });

        colorTagCard = rootView.findViewById(R.id.search_color_card);
        colorTagTextView = (TextView) rootView.findViewById(R.id.search_color_textview);
        colorTagTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showColorPickerDialog();
            }
        });
        colorTagClearButton = (ImageButton) rootView.findViewById(R.id.search_color_button_clear);
        colorTagClearButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                colorTagCard.setVisibility(View.GONE);
                colorPickerButton.setVisibility(View.VISIBLE);
                currentColor = null;
                query = quickReturnEditText.getText().toString();
                gridView.setAdapter(null);
                showLoader();
                getImages(1, query);
            }
        });

        setupAutoSizeGridView();
        if (savedInstanceState != null && savedInstanceState.containsKey(STATE_IMAGES)) {
            query = savedInstanceState.getString(STATE_QUERY, "");
            Message msgObj = uiHandler.obtainMessage();
            msgObj.what = MSG_IMAGES_REQUEST_CREATE;
            msgObj.arg1 = 1;
            msgObj.obj = savedInstanceState.getParcelableArrayList(STATE_IMAGES);
            uiHandler.sendMessage(msgObj);
            currentColor = savedInstanceState.getString(STATE_COLOR);
            if (currentColor != null) {
                int backgroundColor = Color.parseColor("#" + currentColor);
                int textColor = savedInstanceState.getInt(STATE_COLOR_TEXT);
                colorizeColorTag(backgroundColor, textColor, textColor, currentColor);
                colorTagCard.setVisibility(View.VISIBLE);
                colorPickerButton.setVisibility(View.GONE);
            }
            currentPage = savedInstanceState.getInt(STATE_CURRENT_PAGE);
            ((MainActivity) getActivity()).addOnFileChangedListener(this);
            ((MainActivity) getActivity()).addOnFiltersChangedListener(this);
        }
    }
    return rootView;
}

From source file:com.trk.aboutme.facebook.widget.PickerFragment.java

private void inflateTitleBar(ViewGroup view) {
    ViewStub stub = (ViewStub) view.findViewById(R.id.com_facebook_picker_title_bar_stub);
    if (stub != null) {
        View titleBar = stub.inflate();

        final RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
        layoutParams.addRule(RelativeLayout.BELOW, R.id.com_facebook_picker_title_bar);
        listView.setLayoutParams(layoutParams);

        if (titleBarBackground != null) {
            titleBar.setBackgroundDrawable(titleBarBackground);
        }/* w w  w  .  j av a 2 s.  c om*/

        doneButton = (Button) view.findViewById(R.id.com_facebook_picker_done_button);
        if (doneButton != null) {
            doneButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (onDoneButtonClickedListener != null) {
                        onDoneButtonClickedListener.onDoneButtonClicked(PickerFragment.this);
                    }
                }
            });

            if (getDoneButtonText() != null) {
                doneButton.setText(getDoneButtonText());
            }

            if (doneButtonBackground != null) {
                doneButton.setBackgroundDrawable(doneButtonBackground);
            }
        }

        titleTextView = (TextView) view.findViewById(R.id.com_facebook_picker_title);
        if (titleTextView != null) {
            if (getTitleText() != null) {
                titleTextView.setText(getTitleText());
            }
        }
    }
}

From source file:com.bitants.wally.fragments.SearchFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) {
    final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_search, container, false);
    if (rootView != null) {
        super.onCreateView(rootView);
        quickReturnBackground = rootView.findViewById(R.id.quick_return_protective_background);
        quickReturnView = rootView.findViewById(R.id.quick_return_view);
        quickReturnEditTextClearButton = (ImageButton) rootView.findViewById(R.id.quick_return_edittext_clear);
        quickReturnEditTextClearButton.setOnClickListener(new View.OnClickListener() {
            @Override/*from  w  ww.  ja  v  a 2 s.co m*/
            public void onClick(View v) {
                if (quickReturnEditText != null) {
                    query = "";
                    quickReturnEditText.setText("");
                    quickReturnEditText.performClick();
                    showKeyboard(quickReturnEditText);
                }
            }
        });
        quickReturnEditText = (EditText) rootView.findViewById(R.id.quick_return_edittext);
        quickReturnEditText.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                quickReturnEditText.setCursorVisible(true);
                restoreQuickReturnView();
            }
        });
        quickReturnEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                    return search();
                }
                return false;
            }

        });
        quickReturnEditText.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                if (!TextUtils.isEmpty(s)) {
                    quickReturnEditTextClearButton.setVisibility(View.VISIBLE);
                } else {
                    quickReturnEditTextClearButton.setVisibility(View.GONE);
                }
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });

        gridView.setOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);

                float currentTranslationY = quickReturnView.getTranslationY();
                float maxTranslationY = quickReturnHeight;
                float newTranslationY = currentTranslationY + -dy;

                if (newTranslationY > 0) {
                    newTranslationY = 0;
                } else if (newTranslationY < -maxTranslationY) {
                    newTranslationY = -maxTranslationY;
                }
                quickReturnView.setTranslationY(newTranslationY);

                float percent = (-maxTranslationY) / 100.0f;
                float currentPercent = 100 - (newTranslationY / percent);

                quickReturnBackground.setAlpha(currentPercent / 100);
                quickReturnBackground.setTranslationY(newTranslationY);

            }
        });

        colorPickerButton = rootView.findViewById(R.id.quick_return_color_picker);
        colorPickerButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showColorPickerDialog();

            }
        });

        colorTagCard = rootView.findViewById(R.id.search_color_card);
        colorTagTextView = (TextView) rootView.findViewById(R.id.search_color_textview);
        colorTagTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showColorPickerDialog();
            }
        });
        colorTagClearButton = (ImageButton) rootView.findViewById(R.id.search_color_button_clear);
        colorTagClearButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                colorTagCard.setVisibility(View.GONE);
                colorPickerButton.setVisibility(View.VISIBLE);
                currentColor = null;
                query = quickReturnEditText.getText().toString();
                gridView.setAdapter(null);
                showLoader();
                getImages(1, query);
            }
        });

        setupAutoSizeGridView();
        if (savedInstanceState != null && savedInstanceState.containsKey(STATE_IMAGES)) {
            query = savedInstanceState.getString(STATE_QUERY, "");
            Message msgObj = uiHandler.obtainMessage();
            msgObj.what = MSG_IMAGES_REQUEST_CREATE;
            msgObj.arg1 = 1;
            msgObj.obj = savedInstanceState.getParcelableArrayList(STATE_IMAGES);
            uiHandler.sendMessage(msgObj);
            currentColor = savedInstanceState.getString(STATE_COLOR);
            if (currentColor != null) {
                int backgroundColor = Color.parseColor("#" + currentColor);
                int textColor = savedInstanceState.getInt(STATE_COLOR_TEXT);
                colorizeColorTag(backgroundColor, textColor, textColor, currentColor);
                colorTagCard.setVisibility(View.VISIBLE);
                colorPickerButton.setVisibility(View.GONE);
            }
            currentPage = savedInstanceState.getInt(STATE_CURRENT_PAGE);
        }
        ((MainActivity) getActivity()).addOnFileChangedListener(this);
        ((MainActivity) getActivity()).addOnFiltersChangedListener(this);
    }
    return rootView;
}

From source file:mobisocial.musubi.ui.FeedDetailsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = this;
    setContentView(R.layout.feed_details);
    setTitle("Feed Details");
    mDb = new DatabaseManager(this);

    SQLiteOpenHelper helper = App.getDatabaseSource(this);
    mIdentitiesManager = new IdentitiesManager(helper);
    mContacts = new ContactListCursorAdapter(this, null);

    mFeedMembersView = (ListView) findViewById(R.id.feed_details_members_list);
    LayoutInflater inflater = getLayoutInflater();
    ViewGroup header = (ViewGroup) inflater.inflate(R.layout.feed_details_header, mFeedMembersView, false);
    mFeedMembersView.addHeaderView(header, null, false);
    mFeedMembersView.setTextFilterEnabled(true);
    mFeedMembersView.setFastScrollEnabled(true);
    mFeedMembersView.setOnItemClickListener(this);
    mFeedMembersView.setCacheColorHint(Color.WHITE);
    mFeedMembersView.setAdapter(mContacts);

    mNameEditText = (EditText) header.findViewById(R.id.feed_title_edittext);
    mBroadcastPassword = (EditText) header.findViewById(R.id.broadcast_password);
    mThumbnailView = (ImageView) header.findViewById(R.id.icon);

    String name = null;//  w ww  . j  av a2s. co m
    if (savedInstanceState != null) {
        name = savedInstanceState.getString("name");
        mThumbnailBytes = savedInstanceState.getByteArray("thumbnailBytes");
        mDetailsChanged = savedInstanceState.getBoolean("detailsChanged");
    } else {
        Long feedId = Long.parseLong(getIntent().getData().getLastPathSegment());
        MFeed feed = mDb.getFeedManager().lookupFeed(feedId);
        name = UiUtil.getFeedNameFromMembersList(mDb.getFeedManager(), feed);
        mThumbnailBytes = mDb.getFeedManager().getFeedThumbnailForId(feedId);
    }
    Spannable span = EmojiSpannableFactory.getInstance(this).newSpannable(name);
    mNameEditText.setText(span);
    mNameEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            mDetailsChanged = true;
            refreshUI();
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            EmojiSpannableFactory.getInstance(mContext).updateSpannable(s);
        }
    });

    getSupportLoaderManager().initLoader(0, null, this);
    refreshUI();
}

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

@SuppressLint("SetJavaScriptEnabled")
@Override/*from  w w  w.  j ava2s.  c om*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) {
    ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_medication_nlh, 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_nlh_content);

    WebSettings webSettings = WEBVIEW.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setAppCacheEnabled(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setAppCachePath(context.getCacheDir().getAbsolutePath());
    webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);

    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(".*/[^#]+#[^/]+$")) {
                WEBVIEW.loadUrl(url.replaceAll("#[^/]+$", ""));
                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;
}