Example usage for android.view ViewGroup FOCUS_BEFORE_DESCENDANTS

List of usage examples for android.view ViewGroup FOCUS_BEFORE_DESCENDANTS

Introduction

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

Prototype

int FOCUS_BEFORE_DESCENDANTS

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

Click Source Link

Document

This view will get focus before any of its descendants.

Usage

From source file:Main.java

public static void disableAutoScrollToBottom(ScrollView scrollView) {
    scrollView.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
    scrollView.setFocusable(true);/*from  w w w  .  jav  a 2 s  .c  om*/
    scrollView.setFocusableInTouchMode(true);
    scrollView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View arg0, MotionEvent arg1) {
            arg0.requestFocusFromTouch();
            return false;
        }
    });
}

From source file:com.df.kia.carsChecked.BasicInfoLayout.java

private void init(Context context, JSONObject procedures, String seriesId, String modelId) {
    rootView = (ViewGroup) LayoutInflater.from(context).inflate(R.layout.car_report_basic_layout, this);

    MyScrollView scrollView = (MyScrollView) findViewById(R.id.root);
    scrollView.setListener(new MyScrollView.ScrollViewListener() {
        @Override// ww  w  . ja  v  a2 s .  c o  m
        public void onScrollChanged(MyScrollView scrollView, int x, int y, int oldx, int oldy) {
            if (scrollView.getScrollY() > 5) {
                showShadow(true);
            } else {
                showShadow(false);
            }
        }
    });

    // ??????
    scrollView.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
    scrollView.setFocusable(true);
    scrollView.setFocusableInTouchMode(true);
    scrollView.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            v.requestFocusFromTouch();
            return false;
        }
    });

    try {
        fillInData(procedures, seriesId, modelId);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:com.df.app.carsChecked.BasicInfoLayout.java

private void init(Context context, JSONObject procedures, String seriesId, String modelId) {
    rootView = (ViewGroup) LayoutInflater.from(context).inflate(R.layout.car_report_basic_layout, this);

    MyScrollView scrollView = (MyScrollView) findViewById(R.id.root);
    scrollView.setListener(new MyScrollView.ScrollViewListener() {
        @Override/*from w  ww.  j av a  2s.co  m*/
        public void onScrollChanged(MyScrollView scrollView, int x, int y, int oldx, int oldy) {
            if (scrollView.getScrollY() > 5) {
                showShadow(true);
            } else {
                showShadow(false);
            }
        }
    });

    // ??????
    scrollView.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
    scrollView.setFocusable(true);
    scrollView.setFocusableInTouchMode(true);
    scrollView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            v.requestFocusFromTouch();
            return false;
        }
    });

    try {
        fillInData(procedures, seriesId, modelId);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:com.taobao.weex.ui.component.WXVContainer.java

/**
 * Container will get focus before any of its descendants.
 *///  w w w .  j av  a  2s .com
public void interceptFocus() {
    T host = getHostView();
    if (host != null) {
        host.setFocusable(true);
        host.setFocusableInTouchMode(true);
        host.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
        host.requestFocus();
    }
}

From source file:de.madvertise.android.sdk.MadView.java

/**
 * Constructor/*from  w  ww. j av  a 2 s .  c  om*/
 * 
 * @param context
 * @param attrs
 */
public MadView(Context context, AttributeSet attrs) {
    super(context, attrs);

    MadUtil.logMessage(null, Log.DEBUG, "** Constructor for mad view called **");
    setVisibility(INVISIBLE);

    if (context.checkCallingOrSelfPermission(
            android.Manifest.permission.INTERNET) == PackageManager.PERMISSION_DENIED) {

        MadUtil.logMessage(null, Log.DEBUG, " *** ----------------------------- *** ");
        MadUtil.logMessage(null, Log.DEBUG, " *** Missing internet permissions! *** ");
        MadUtil.logMessage(null, Log.DEBUG, " *** ----------------------------- *** ");
        throw new IllegalArgumentException();
    }

    initParameters(attrs);

    Display display = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE))
            .getDefaultDisplay();
    MadUtil.logMessage(null, Log.DEBUG,
            "Display values: Width = " + display.getWidth() + " ; Height = " + display.getHeight());

    setGravity(Gravity.CENTER);

    initialBackground = this.getBackground();
    Rect r = new Rect(0, 0, display.getWidth(), display.getHeight());
    textBannerBackground = generateBackgroundDrawable(r, backgroundColor, 0xffffff);

    setClickable(true);
    setFocusable(true);
    setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
}

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) {//  w w  w.ja  va2 s. c  o  m
        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:de.madvertise.android.sdk.MadvertiseView.java

/**
 * Constructor/* ww w.j a  v a 2  s .c o  m*/
 *
 * @param context
 * @param attrs
 */
public MadvertiseView(final Context context, final AttributeSet attrs) {
    super(context, attrs);

    MadvertiseUtil.logMessage(null, Log.DEBUG, "** Constructor for mad view called **");

    // We use GONE instead of INVISIBLE because GONE doesn't allocate space
    // in
    // the layout.
    setVisibility(GONE);

    if (!MadvertiseUtil.checkPermissionGranted(android.Manifest.permission.INTERNET, context)) {
        MadvertiseUtil.logMessage(null, Log.DEBUG, " *** ----------------------------- *** ");
        MadvertiseUtil.logMessage(null, Log.DEBUG, " *** Missing internet permissions! *** ");
        MadvertiseUtil.logMessage(null, Log.DEBUG, " *** ----------------------------- *** ");
        throw new IllegalArgumentException("Missing internet permission!");
    }

    if (!MadvertiseUtil.checkForBrowserDeclaration(getContext())) {
        MadvertiseUtil.logMessage(null, Log.DEBUG, " *** ----------------------------- *** ");
        MadvertiseUtil.logMessage(null, Log.DEBUG,
                " *** You must declare the activity de.madvertise.android.sdk.MadvertiseActivity in your manifest! *** ");
        MadvertiseUtil.logMessage(null, Log.DEBUG, " *** ----------------------------- *** ");
        throw new IllegalArgumentException("Missing Activity declaration!");
    }

    initParameters(attrs);

    final DisplayMetrics displayMetrics = context.getApplicationContext().getResources().getDisplayMetrics();
    MadvertiseUtil.logMessage(null, Log.DEBUG, "Display values: Width = " + displayMetrics.widthPixels
            + " ; Height = " + displayMetrics.heightPixels);

    mInitialBackground = this.getBackground();
    if (sTextBannerBackground == null) {
        Rect r = new Rect(0, 0, 1, displayMetrics.heightPixels);
        sTextBannerBackground = generateBackgroundDrawable(r, mBackgroundColor, 0xffffff);
    }

    setClickable(true);
    setFocusable(true);
    setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);

    if (mRequestThread == null || !mRequestThread.isAlive()) {
        requestNewAd(false);
    }

    // no reloads for ads with banner_type = rich_media
    if (mBannerType.contains(MadvertiseUtil.BANNER_TYPE_RICH_MEDIA)
            || mBannerType.contains(MadvertiseUtil.BANNER_TYPE_RICH_MEDIA_SHORT)) {
        this.setFetchingAdsEnabled(false);
        MadvertiseUtil.logMessage(null, Log.DEBUG,
                "No ad reloading, since banner_type=[rich_media|rm] was requested");
    }

    // just some testing
    // MadvertiseUtil.getPackages(context.getApplicationContext());

}

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 av  a 2  s.c  o m
        mListView.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
        mListView.requestFocus();
    }

}

From source file:com.df.dfcarchecker.CarCheck.CarCheckBasicInfoFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //        Random r=new Random();
    //        int uniqueNumber =(r.nextInt(999) + 100);
    //        uniqueId = Integer.toString(uniqueNumber);

    // ?uniqueId//from   w ww.  j  a va2 s. c  om
    UUID uuid = UUID.randomUUID();
    uniqueId = uuid.toString();

    this.inflater = inflater;
    rootView = inflater.inflate(R.layout.fragment_car_check_basic_info, container, false);

    // <editor-fold defaultstate="collapsed" desc="??View?">
    tableLayout = (TableLayout) rootView.findViewById(R.id.bi_content_table);

    contentLayout = (LinearLayout) rootView.findViewById(R.id.brand_input);

    Button vinButton = (Button) rootView.findViewById(R.id.bi_vin_button);
    vinButton.setOnClickListener(this);

    brandOkButton = (Button) rootView.findViewById(R.id.bi_brand_ok_button);
    brandOkButton.setEnabled(false);
    brandOkButton.setOnClickListener(this);

    brandSelectButton = (Button) rootView.findViewById(R.id.bi_brand_select_button);
    brandSelectButton.setEnabled(false);
    brandSelectButton.setOnClickListener(this);

    // ??
    sketchPhotoEntities = new ArrayList<PhotoEntity>();

    // 
    Button matchButton = (Button) rootView.findViewById(R.id.ct_licencePhotoMatch_button);
    matchButton.setOnClickListener(this);

    // vin???
    InputFilter alphaNumericFilter = new InputFilter() {
        @Override
        public CharSequence filter(CharSequence arg0, int arg1, int arg2, Spanned arg3, int arg4, int arg5) {
            for (int k = arg1; k < arg2; k++) {
                if (!Character.isLetterOrDigit(arg0.charAt(k))) {
                    return "";
                }
            }
            return null;
        }
    };
    vin_edit = (EditText) rootView.findViewById(R.id.bi_vin_edit);
    vin_edit.setFilters(new InputFilter[] { alphaNumericFilter, new InputFilter.AllCaps() });

    brandEdit = (EditText) rootView.findViewById(R.id.bi_brand_edit);
    displacementEdit = (EditText) rootView.findViewById(R.id.csi_displacement_edit);
    transmissionEdit = (EditText) rootView.findViewById(R.id.csi_transmission_edit);
    runEdit = (EditText) rootView.findViewById(R.id.bi_mileage_edit);
    //
    //        transmissionSpinner = (Spinner)rootView.findViewById(R.id.csi_transmission_spinner);
    //        transmissionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
    //            @Override
    //            public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
    //                transmissionEdit.setText(adapterView.getSelectedItem().toString());
    //            }
    //
    //            @Override
    //            public void onNothingSelected(AdapterView<?> adapterView) {
    //
    //            }
    //        });

    // ??????
    ScrollView view = (ScrollView) rootView.findViewById(R.id.root);
    view.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            v.requestFocusFromTouch();
            return false;
        }
    });

    // ????????2?
    runEdit.addTextChangedListener(new TextWatcher() {
        public void afterTextChanged(Editable edt) {
            String temp = edt.toString();

            if (temp.contains(".")) {
                int posDot = temp.indexOf(".");
                if (posDot <= 0)
                    return;
                if (temp.length() - posDot - 1 > 2) {
                    edt.delete(posDot + 3, posDot + 4);
                }
            } else {
                if (temp.length() > 2) {
                    edt.clear();
                    edt.append(temp.substring(0, 2));
                }
            }
        }

        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
        }

        public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
        }
    });

    licencePhotoMatchEdit = (EditText) rootView.findViewById(R.id.ct_licencePhotoMatch_edit);
    licencePhotoMatchEdit.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            licencePhotoMatchEdit.setError(null);
        }

        @Override
        public void afterTextChanged(Editable editable) {
            licencePhotoMatchEdit.setError(null);
        }
    });

    // ??
    carNumberEdit = (EditText) rootView.findViewById(R.id.ci_plateNumber_edit);
    carNumberEdit.setFilters(new InputFilter[] { new InputFilter.AllCaps(), new InputFilter.LengthFilter(10) });

    // ?
    portedProcedureRow = (TableRow) rootView.findViewById(R.id.ct_ported_procedure);

    // ?Spinner
    setRegLocationSpinner();
    setCarColorSpinner();
    setFirstLogTimeSpinner();
    setManufactureTimeSpinner();
    setTransferCountSpinner();
    setLastTransferTimeSpinner();
    setYearlyCheckAvailableDateSpinner();
    setAvailableDateYearSpinner();
    setBusinessInsuranceAvailableDateYearSpinner();
    setOtherSpinners();
    // </editor-fold>

    mCarSettings = new CarSettings();

    // ??xml
    if (vehicleModel == null) {
        mProgressDialog = ProgressDialog.show(rootView.getContext(), null, "?..", false, false);

        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    ParseXml();

                    // jsonData??
                    if (!jsonData.equals("")) {
                        modifyMode = true;
                        letsEnterModifyMode();
                    }

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

        thread.start();
    }

    return rootView;
}