Example usage for android.view ViewGroup FOCUS_AFTER_DESCENDANTS

List of usage examples for android.view ViewGroup FOCUS_AFTER_DESCENDANTS

Introduction

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

Prototype

int FOCUS_AFTER_DESCENDANTS

To view the source code for android.view ViewGroup FOCUS_AFTER_DESCENDANTS.

Click Source Link

Document

This view will get focus only if none of its descendants want it.

Usage

From source file:org.mariotaku.twidere.fragment.ActivityHostFragment.java

@SuppressWarnings({ "deprecation", "unchecked" })
@Override//from  ww  w  .j a  va 2s.c  om
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final Intent intent = new Intent(getActivity(), getActivityClass());
    final Bundle args = getArguments();
    if (args != null) {
        intent.putExtras(args);
    }

    final Window w = getLocalActivityManager().startActivity(ACTIVITY_TAG, intent);
    mAttachedActivity = null;
    final Context context = w.getContext();
    if (context instanceof Activity) {
        try {
            mAttachedActivity = (A) context;
            if (context instanceof FragmentCallback) {
                ((FragmentCallback<A>) context).setCallbackFragment(this);
            }
        } catch (final ClassCastException e) {
            // This should't happen.
            e.printStackTrace();
        }
    }
    final View wd = w != null ? w.getDecorView() : null;

    if (wd != null) {
        final ViewParent parent = wd.getParent();
        if (parent != null) {
            final ViewGroup v = (ViewGroup) parent;
            v.removeView(wd);
        }

        wd.setVisibility(View.VISIBLE);
        wd.setFocusableInTouchMode(true);
        if (wd instanceof ViewGroup) {
            ((ViewGroup) wd).setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
        }
    }
    return wd;
}

From source file:edu.cmu.android.restaurant.MapFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Intent intent = new Intent(getActivity(), MyMapActivity.class);

    final Window w = getLocalActivityManager().startActivity("tag", intent);
    final View wd = w != null ? w.getDecorView() : null;

    if (wd != null) {
        ViewParent parent = wd.getParent();
        if (parent != null) {
            ViewGroup v = (ViewGroup) parent;
            v.removeView(wd);//from  w  w w. j ava2s.  c  om
        }

        wd.setVisibility(View.VISIBLE);
        wd.setFocusableInTouchMode(true);
        if (wd instanceof ViewGroup) {
            ((ViewGroup) wd).setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
        }
    }

    ((MyMapActivity) mLocalActivityManager.getActivity("tag")).registerListener(mListener);

    setHasOptionsMenu(true); // add menu in fragment
    sensorManager = (SensorManager) getActivity().getSystemService(Activity.SENSOR_SERVICE);
    vibrator = (Vibrator) getActivity().getSystemService(Service.VIBRATOR_SERVICE);
    dealList = mListener.onDealsRequested();

    return wd;

}

From source file:im.ene.lab.io_timer.ui.widget.MiniDrawerLayout.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public MiniDrawerLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
    // as recommended
    setWillNotDraw(false);//from  w  w w . j a v  a  2s  . co m
    // Custom attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MiniDrawerLayout, defStyleAttr,
            defStyleRes);
    mCollapseWidth = a.getDimensionPixelSize(R.styleable.MiniDrawerLayout_collapseWidth, 0);
    mExpandWidth = a.getDimensionPixelSize(R.styleable.MiniDrawerLayout_expandWidth, 0);

    a.recycle();

    // View dragger
    final float density = getResources().getDisplayMetrics().density;
    final float minVel = MIN_FLING_VELOCITY * density;

    ViewDragCallback mDraggerCallback = new ViewDragCallback();
    mDragHelper = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mDraggerCallback);
    mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT);
    mDragHelper.setMinVelocity(minVel);

    mDraggerCallback.setDragger(mDragHelper);

    // So that we can catch the back button
    setFocusableInTouchMode(true);

    ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
    ViewGroupCompat.setMotionEventSplittingEnabled(this, false);

    mNonDrawerViews = new ArrayList<>();
}

From source file:edu.stanford.mobisocial.dungbeetle.ui.FeedHomeActivity.java

/** Called when the activity is first created. */
@Override/*from w w  w  .java2s .  co  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_feed_home);
    mNfc = new Nfc(this);

    checked = new boolean[filterTypes.length];

    for (int x = 0; x < filterTypes.length; x++) {
        checked[x] = true;
    }

    mFeedViews = new ArrayList<FeedView>();
    mFeedViews.add(FeedViews.feedViewFrom("Feed", new FeedViewFragment()));
    mFeedViews.add(FeedViews.feedViewFrom("Apps", new AppsViewFragment()));
    mFeedViews.add(FeedViews.feedViewFrom("People", new FeedMembersFragment()));
    mFeedViews.add(new PresenceView());

    Intent intent = getIntent();
    String feed_name = null;
    String dyn_feed_uri = null;
    if (intent.getType() != null && intent.getType().equals(Feed.MIME_TYPE)) {
        Uri feedUri = getIntent().getData();
        feed_name = feedUri.getLastPathSegment();
        Maybe<Group> maybeG = Group.forFeedName(FeedHomeActivity.this, feed_name);
        try {
            Group g = maybeG.get();
            mGroupName = g.name;
            dyn_feed_uri = g.dynUpdateUri;
        } catch (Exception e) {
        }
    }

    if (dyn_feed_uri != null) {
        mNfc.share(NdefFactory.fromUri(dyn_feed_uri));
        Log.w(TAG, dyn_feed_uri);
    }

    mFeedUri = Feed.uriForName(feed_name);
    mColor = Feed.colorFor(feed_name);

    Bundle args = new Bundle();
    args.putParcelable(FeedViewFragment.ARG_FEED_URI, mFeedUri);
    mActionsFragment = new FeedActionsFragment();
    mActionsFragment.setArguments(args);

    for (FeedView f : mFeedViews) {
        f.getFragment().setArguments(args);
    }

    // TODO: Why is FeedActionsFragment.getActivity() null without this hack?
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    Fragment actions = getSupportFragmentManager().findFragmentByTag("feedActions");
    if (actions != null) {
        ft.remove(actions);
    }
    ft.add(mActionsFragment, "feedActions");
    ft.commit();

    PagerAdapter adapter = new FeedFragmentAdapter(getSupportFragmentManager(), mFeedUri);
    mFeedViewPager = (ViewPager) findViewById(R.id.feed_pager);
    mFeedViewPager.setAdapter(adapter);
    mFeedViewPager.setOnPageChangeListener(this);
    mFeedViewPager.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);

    ViewGroup group = (ViewGroup) findViewById(R.id.tab_frame);
    int i = 0;
    for (FeedView f : mFeedViews) {
        Button button = new Button(this);
        button.setText(f.getName());
        button.setTextSize(18f);

        button.setLayoutParams(CommonLayouts.FULL_HEIGHT);
        button.setTag(i++);
        button.setOnClickListener(mViewSelected);

        group.addView(button);
        mButtons.add(button);
    }

    doTitleBar(this, mGroupName);
    onPageSelected(0);
}

From source file:android.support.v17.leanback.widget.DetailsOverviewSharedElementHelper.java

@Override
public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements,
        List<View> sharedElementSnapshots) {
    if (DEBUG) {/*ww  w. j a  v  a2  s.c om*/
        Log.d(TAG, "onSharedElementEnd " + mActivityToRunTransition);
    }
    if (sharedElements.size() < 1) {
        return;
    }
    View overviewView = sharedElements.get(0);
    if (mViewHolder == null || mViewHolder.mOverviewFrame != overviewView) {
        return;
    }
    restoreImageViewScale();
    // temporary let action row take focus so we defer button background animation
    mViewHolder.mActionsRow.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
    mViewHolder.mActionsRow.setVisibility(View.VISIBLE);
    mViewHolder.mActionsRow.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
    mViewHolder.mDetailsDescriptionFrame.setVisibility(View.VISIBLE);
}

From source file:org.ohmage.prompt.multichoicecustom.MultiChoiceCustomPrompt.java

@Override
public View getView(final Context context) {

    mCustomChoices.clear();//from  w  w w.  ja v a 2  s.  c  o m
    MultiChoiceCustomDbAdapter dbAdapter = new MultiChoiceCustomDbAdapter(context);
    String surveyId = ((SurveyActivity) context).getSurveyId();
    SharedPreferencesHelper prefs = new SharedPreferencesHelper(context);
    String campaignUrn = ((SurveyActivity) context).getCampaignUrn();
    String username = prefs.getUsername();
    if (dbAdapter.open()) {
        Cursor c = dbAdapter.getCustomChoices(username, campaignUrn, surveyId,
                MultiChoiceCustomPrompt.this.getId());
        c.moveToFirst();
        for (int i = 0; i < c.getCount(); i++) {
            //c.getLong(c.getColumnIndex(MultiChoiceCustomDbAdapter.KEY_ID));
            int key = c.getInt(c.getColumnIndex(MultiChoiceCustomDbAdapter.KEY_CHOICE_ID));
            String label = c.getString(c.getColumnIndex(MultiChoiceCustomDbAdapter.KEY_CHOICE_VALUE));
            mCustomChoices.add(new KVLTriplet(String.valueOf(key), null, label));
            c.moveToNext();
        }
        c.close();
        dbAdapter.close();
    }

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    //      mListView = (ListView) inflater.inflate(R.layout.prompt_single_choice_custom, null);
    mListView = new CustomChoiceListView(context);
    mListView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    mListView.setTextFilterEnabled(false);

    mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    mListView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);

    mFooterView = inflater.inflate(R.layout.custom_choice_footer, null);

    EditText mEditText = (EditText) mFooterView.findViewById(R.id.new_choice_edit);
    ImageButton mButton = (ImageButton) mFooterView.findViewById(R.id.ok_button);
    ImageButton mCancelButton = (ImageButton) mFooterView.findViewById(R.id.cancel_button);

    showAddItemControls(context, mIsAddingNewItem);

    mButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (mEnteredText != null && !mEnteredText.equals("")) {
                MultiChoiceCustomDbAdapter dbAdapter = new MultiChoiceCustomDbAdapter(context);
                String surveyId = ((SurveyActivity) context).getSurveyId();
                SharedPreferencesHelper prefs = new SharedPreferencesHelper(context);
                String campaignUrn = ((SurveyActivity) context).getCampaignUrn();
                String username = prefs.getUsername();

                int choiceId = 100;
                ArrayList<String> keys = new ArrayList<String>();
                for (KVLTriplet choice : mChoices) {
                    keys.add(choice.key.trim());
                }
                for (KVLTriplet choice : mCustomChoices) {
                    keys.add(choice.key.trim());
                }
                while (keys.contains(String.valueOf(choiceId))) {
                    choiceId++;
                }

                if (dbAdapter.open()) {
                    dbAdapter.addCustomChoice(choiceId, mEnteredText, username, campaignUrn, surveyId,
                            MultiChoiceCustomPrompt.this.getId());
                    dbAdapter.close();
                }

                showAddItemControls(context, false);

                mSelectedIndexes.add(Integer.valueOf(mListView.getCount() - 1));

                ((SurveyActivity) context).reloadCurrentPrompt();
            } else {
                Toast.makeText(context, "Please enter some text", Toast.LENGTH_SHORT).show();
            }
        }
    });

    mCancelButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            //            EditText edit = (EditText) mFooterView.findViewById(R.id.new_choice_edit);
            showAddItemControls(context, false);
        }
    });

    mEditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub

        }

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub
            mEnteredText = s.toString();
            //            mListView.setSelectionFromTop(mLastIndex, mLastTop);
            //            EditText editText = (EditText) mFooterView.findViewById(R.id.new_choice_edit);
            //            editText.requestFocus();
        }
    });

    mListView.addFooterView(mFooterView);

    String[] from = new String[] { "value" };
    int[] to = new int[] { android.R.id.text1 };

    List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>();
    for (int i = 0; i < mChoices.size(); i++) {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("key", mChoices.get(i).key);
        map.put("value", mChoices.get(i).label);
        data.add(map);
    }
    for (int i = 0; i < mCustomChoices.size(); i++) {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("key", mCustomChoices.get(i).key);
        map.put("value", mCustomChoices.get(i).label);
        data.add(map);
    }

    SimpleAdapter adapter = new SimpleAdapter(context, data, R.layout.multi_choice_list_item, from, to);

    adapter.setViewBinder(new ViewBinder() {

        @Override
        public boolean setViewValue(View view, Object data, String textRepresentation) {
            ((CheckedTextView) view).setText((String) data);
            return true;
        }
    });

    mListView.setAdapter(adapter);

    if (mSelectedIndexes.size() > 0) {
        for (int index : mSelectedIndexes) {
            if (index >= 0 && index < mChoices.size() + mCustomChoices.size())
                mListView.setItemChecked(index, true);
        }
    }

    mListView.setOnItemClickListener(new OnItemClickListener() {

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

            if (position == mListView.getCount() - 1) {
                showAddItemControls(context, true);
                mLastIndex = mListView.getLastVisiblePosition();
                View v = mListView.getChildAt(mLastIndex);
                mLastTop = (v == null) ? 0 : v.getTop();
                mListView.setSelectionFromTop(mLastIndex, mLastTop);
            } else {
                //SparseBooleanArray checkItemPositions = ((ListView)parent).getCheckedItemPositions();
                if (((ListView) parent).isItemChecked(position)) {
                    mSelectedIndexes.add(Integer.valueOf(position));
                } else {
                    mSelectedIndexes.remove(Integer.valueOf(position));
                }
            }
        }
    });

    mListView.setSelectionFromTop(mLastIndex, mLastTop);

    return mListView;
}

From source file:org.ohmage.prompt.singlechoicecustom.SingleChoiceCustomPrompt.java

@Override
public View getView(final Context context) {

    mCustomChoices.clear();//from ww w . j  a  va  2s  .c o  m
    SingleChoiceCustomDbAdapter dbAdapter = new SingleChoiceCustomDbAdapter(context);
    String surveyId = ((SurveyActivity) context).getSurveyId();
    SharedPreferencesHelper prefs = new SharedPreferencesHelper(context);
    String campaignUrn = ((SurveyActivity) context).getCampaignUrn();
    String username = prefs.getUsername();
    if (dbAdapter.open()) {
        Cursor c = dbAdapter.getCustomChoices(username, campaignUrn, surveyId,
                SingleChoiceCustomPrompt.this.getId());
        c.moveToFirst();
        for (int i = 0; i < c.getCount(); i++) {
            //c.getLong(c.getColumnIndex(SingleChoiceCustomDbAdapter.KEY_ID));
            int key = c.getInt(c.getColumnIndex(SingleChoiceCustomDbAdapter.KEY_CHOICE_ID));
            String label = c.getString(c.getColumnIndex(SingleChoiceCustomDbAdapter.KEY_CHOICE_VALUE));
            mCustomChoices.add(new KVLTriplet(String.valueOf(key), null, label));
            c.moveToNext();
        }
        c.close();
        dbAdapter.close();
    }

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    //      mListView = (ListView) inflater.inflate(R.layout.prompt_single_choice_custom, null);
    mListView = new CustomChoiceListView(context);
    mListView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    mListView.setTextFilterEnabled(false);

    mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    mListView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);

    mFooterView = inflater.inflate(R.layout.custom_choice_footer, null);

    EditText mEditText = (EditText) mFooterView.findViewById(R.id.new_choice_edit);
    ImageButton mButton = (ImageButton) mFooterView.findViewById(R.id.ok_button);
    ImageButton mCancelButton = (ImageButton) mFooterView.findViewById(R.id.cancel_button);

    showAddItemControls(context, mIsAddingNewItem);

    mButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (mEnteredText != null && !mEnteredText.equals("")) {
                SingleChoiceCustomDbAdapter dbAdapter = new SingleChoiceCustomDbAdapter(context);
                String surveyId = ((SurveyActivity) context).getSurveyId();
                SharedPreferencesHelper prefs = new SharedPreferencesHelper(context);
                String campaignUrn = ((SurveyActivity) context).getCampaignUrn();
                String username = prefs.getUsername();

                int choiceId = 100;
                ArrayList<String> keys = new ArrayList<String>();
                for (KVLTriplet choice : mChoices) {
                    keys.add(choice.key.trim());
                }
                for (KVLTriplet choice : mCustomChoices) {
                    keys.add(choice.key.trim());
                }
                while (keys.contains(String.valueOf(choiceId))) {
                    choiceId++;
                }

                if (dbAdapter.open()) {
                    dbAdapter.addCustomChoice(choiceId, mEnteredText, username, campaignUrn, surveyId,
                            SingleChoiceCustomPrompt.this.getId());
                    dbAdapter.close();
                }

                showAddItemControls(context, false);

                mSelectedIndex = mListView.getCount() - 1;

                ((SurveyActivity) context).reloadCurrentPrompt();
            } else {
                Toast.makeText(context, "Please enter some text", Toast.LENGTH_SHORT).show();
            }
        }
    });

    mCancelButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            //            EditText edit = (EditText) mFooterView.findViewById(R.id.new_choice_edit);
            showAddItemControls(context, false);
        }
    });

    mEditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub

        }

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub
            mEnteredText = s.toString();
            //            mListView.setSelectionFromTop(mLastIndex, mLastTop);
            //            EditText editText = (EditText) mFooterView.findViewById(R.id.new_choice_edit);
            //            editText.requestFocus();
        }
    });

    mListView.addFooterView(mFooterView);

    String[] from = new String[] { "value" };
    int[] to = new int[] { android.R.id.text1 };

    List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>();
    for (int i = 0; i < mChoices.size(); i++) {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("key", mChoices.get(i).key);
        map.put("value", mChoices.get(i).label);
        data.add(map);
    }
    for (int i = 0; i < mCustomChoices.size(); i++) {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("key", mCustomChoices.get(i).key);
        map.put("value", mCustomChoices.get(i).label);
        data.add(map);
    }

    SimpleAdapter adapter = new SimpleAdapter(context, data, R.layout.single_choice_list_item, from, to);

    adapter.setViewBinder(new ViewBinder() {

        @Override
        public boolean setViewValue(View view, Object data, String textRepresentation) {
            ((CheckedTextView) view).setText((String) data);
            return true;
        }
    });

    mListView.setAdapter(adapter);

    if (mSelectedIndex >= 0 && mSelectedIndex < mChoices.size() + mCustomChoices.size()) {
        mListView.setItemChecked(mSelectedIndex, true);
    }

    mListView.setOnItemClickListener(new OnItemClickListener() {

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

            if (position == mListView.getCount() - 1) {
                showAddItemControls(context, true);
                mSelectedIndex = -1;
                mLastIndex = mListView.getLastVisiblePosition();
                View v = mListView.getChildAt(mLastIndex);
                mLastTop = (v == null) ? 0 : v.getTop();
                mListView.setSelectionFromTop(mLastIndex, mLastTop);
            } else {
                //Map<String, String> map = (HashMap<String, String>) parent.getItemAtPosition(position);
                //mSelectedKey = map.get("key");
                mSelectedIndex = position;
                //((SurveyActivity)context).setResponse(index, id, value)
            }
        }
    });

    mListView.setSelectionFromTop(mLastIndex, mLastTop);

    return mListView;
}

From source file:org.creativecommons.thelist.fragments.MyListFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mContext = getActivity();/*from   w w w .j  a v a 2s.c om*/
    Activity activity = getActivity();

    //Helpers
    mMessageHelper = new MessageHelper(mContext);
    mRequestMethods = new RequestMethods(mContext);
    mSharedPref = new SharedPreferencesMethods(mContext);
    mCurrentUser = new ListUser(getActivity());

    //Load UI Elements
    snackbarContainer = (ViewGroup) activity.findViewById(R.id.snackbar_container);
    mProgressBar = (ProgressBar) activity.findViewById(R.id.feedProgressBar);
    mUploadProgressBarContainer = (RelativeLayout) activity.findViewById(R.id.photoProgressBar);
    //mUploadProgressBar = (com.gc.materialdesign.views.ProgressBarDeterminate) activity.findViewById(R.id.upload_progress);
    //mUploadText = (TextView) activity.findViewById(R.id.upload_text);

    mEmptyView = (TextView) activity.findViewById(R.id.empty_list_label);

    mFab = (FloatingActionButton) activity.findViewById(R.id.fab);
    //mFab.setEnabled(false);
    mFab.setVisibility(View.GONE);
    mFab.hide();

    mFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            if (!NetworkUtils.isNetworkAvailable(mContext)) {
                mMessageHelper.toastNeedInternet();
                return;
            }

            Intent hitMeIntent = new Intent(getActivity(), RandomActivity.class);
            startActivity(hitMeIntent);

        } //onClick
    });

    //RecyclerView
    mSwipeRefreshLayout = (SwipeRefreshLayout) activity.findViewById(R.id.feedSwipeRefresh);
    mRecyclerView = (RecyclerView) activity.findViewById(R.id.feedRecyclerView);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    //TODO: Try dividers in layout instead?
    RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(activity,
            DividerItemDecoration.VERTICAL_LIST);
    mRecyclerView.addItemDecoration(itemDecoration);
    mLayoutManager = new LinearLayoutManager(mContext);
    mFeedAdapter = new UserListAdapter(mContext, mItemList);
    mRecyclerView.setAdapter(mFeedAdapter);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
    initRecyclerView();

    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            displayUserItems();
        }
    });

}

From source file:org.yammp.fragment.ArtistFragment.java

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

    if (view.getTag() != null && view.getTag() instanceof ViewHolderChild) {
        mListView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
        ((ViewHolderChild) view.getTag()).gridview.requestFocus();
    } else {//from w  w  w  .j a  v a  2s .c o m
        mListView.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
        mListView.requestFocus();
    }

}

From source file:de.azapps.mirakel.main_activity.tasks_fragment.TasksFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    this.main = (MainActivity) getActivity();
    this.listId = this.main.getCurrentList().getId();
    this.view = inflater.inflate(R.layout.layout_tasks_fragment, container, false);
    this.adapter = null;
    this.created = true;
    this.listView = (ListView) this.view.findViewById(R.id.tasks_list);
    this.listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
    // Events/*from  w w  w . j a va  2 s .c om*/
    this.newTask = (EditText) this.view.findViewById(R.id.tasks_new);
    if (MirakelCommonPreferences.isTablet()) {
        this.newTask.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25);
    }
    this.newTask.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEND
                    || actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_DOWN) {
                newTask(v.getText().toString());
                v.setText(null);
            }
            return false;
        }
    });
    this.newTask.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(final Editable s) {
            final ImageButton send = (ImageButton) TasksFragment.this.view.findViewById(R.id.btnEnter);
            if (s.length() > 0) {
                send.setVisibility(View.VISIBLE);
            } else {
                send.setVisibility(View.GONE);
            }
        }

        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {
            // Nothing
        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {
            // Nothing
        }
    });
    update(true);
    final ImageButton btnEnter = (ImageButton) this.view.findViewById(R.id.btnEnter);
    btnEnter.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            newTask(TasksFragment.this.newTask.getText().toString());
            TasksFragment.this.newTask.setText(null);
        }
    });
    updateButtons();
    return this.view;
}