Search in sources :

Example 36 with AdapterView

use of android.widget.AdapterView in project flexbox-layout by google.

the class FlexItemEditFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_flex_item_edit, container, false);
    getDialog().setTitle(String.valueOf(mFlexItem.index + 1));
    final TextInputLayout orderTextInput = (TextInputLayout) view.findViewById(R.id.input_layout_order);
    EditText orderEdit = (EditText) view.findViewById(R.id.edit_text_order);
    orderEdit.setText(String.valueOf(mFlexItem.order));
    orderEdit.addTextChangedListener(new FlexEditTextWatcher(orderTextInput, new IntegerInputValidator(), R.string.must_be_integer));
    final TextInputLayout flexGrowInput = (TextInputLayout) view.findViewById(R.id.input_layout_flex_grow);
    final EditText flexGrowEdit = (EditText) view.findViewById(R.id.edit_text_flex_grow);
    flexGrowEdit.setText(String.valueOf(mFlexItem.flexGrow));
    flexGrowEdit.addTextChangedListener(new FlexEditTextWatcher(flexGrowInput, new NonNegativeDecimalInputValidator(), R.string.must_be_non_negative_float));
    final TextInputLayout flexShrinkInput = (TextInputLayout) view.findViewById(R.id.input_layout_flex_shrink);
    EditText flexShrinkEdit = (EditText) view.findViewById(R.id.edit_text_flex_shrink);
    flexShrinkEdit.setText(String.valueOf(mFlexItem.flexShrink));
    flexShrinkEdit.addTextChangedListener(new FlexEditTextWatcher(flexShrinkInput, new NonNegativeDecimalInputValidator(), R.string.must_be_non_negative_float));
    final TextInputLayout flexBasisPercentInput = (TextInputLayout) view.findViewById(R.id.input_layout_flex_basis_percent);
    EditText flexBasisPercentEdit = (EditText) view.findViewById(R.id.edit_text_flex_basis_percent);
    if (mFlexItem.flexBasisPercent != FlexboxLayout.LayoutParams.FLEX_BASIS_PERCENT_DEFAULT) {
        flexBasisPercentEdit.setText(String.valueOf(Math.round(mFlexItem.flexBasisPercent * 100)));
    } else {
        flexBasisPercentEdit.setText(String.valueOf((int) mFlexItem.flexBasisPercent));
    }
    flexBasisPercentEdit.addTextChangedListener(new FlexEditTextWatcher(flexBasisPercentInput, new FlexBasisPercentInputValidator(), R.string.must_be_minus_one_or_non_negative_integer));
    final TextInputLayout widthInput = (TextInputLayout) view.findViewById(R.id.input_layout_width);
    EditText widthEdit = (EditText) view.findViewById(R.id.edit_text_width);
    widthEdit.setText(String.valueOf(mFlexItem.width));
    widthEdit.addTextChangedListener(new FlexEditTextWatcher(widthInput, new DimensionInputValidator(), R.string.must_be_minus_one_or_minus_two_or_non_negative_integer));
    final TextInputLayout heightInput = (TextInputLayout) view.findViewById(R.id.input_layout_height);
    EditText heightEdit = (EditText) view.findViewById(R.id.edit_text_height);
    heightEdit.setText(String.valueOf(mFlexItem.height));
    heightEdit.addTextChangedListener(new FlexEditTextWatcher(heightInput, new DimensionInputValidator(), R.string.must_be_minus_one_or_minus_two_or_non_negative_integer));
    final TextInputLayout minWidthInput = (TextInputLayout) view.findViewById(R.id.input_layout_min_width);
    EditText minWidthEdit = (EditText) view.findViewById(R.id.edit_text_min_width);
    minWidthEdit.setText(String.valueOf(mFlexItem.minWidth));
    minWidthEdit.addTextChangedListener(new FlexEditTextWatcher(minWidthInput, new FixedDimensionInputValidator(), R.string.must_be_non_negative_integer));
    final TextInputLayout minHeightInput = (TextInputLayout) view.findViewById(R.id.input_layout_min_height);
    EditText minHeightEdit = (EditText) view.findViewById(R.id.edit_text_min_height);
    minHeightEdit.setText(String.valueOf(mFlexItem.minHeight));
    minHeightEdit.addTextChangedListener(new FlexEditTextWatcher(minHeightInput, new FixedDimensionInputValidator(), R.string.must_be_non_negative_integer));
    final TextInputLayout maxWidthInput = (TextInputLayout) view.findViewById(R.id.input_layout_max_width);
    EditText maxWidthEdit = (EditText) view.findViewById(R.id.edit_text_max_width);
    maxWidthEdit.setText(String.valueOf(mFlexItem.maxWidth));
    maxWidthEdit.addTextChangedListener(new FlexEditTextWatcher(maxWidthInput, new FixedDimensionInputValidator(), R.string.must_be_non_negative_integer));
    final TextInputLayout maxHeightInput = (TextInputLayout) view.findViewById(R.id.input_layout_max_height);
    EditText maxHeightEdit = (EditText) view.findViewById(R.id.edit_text_max_height);
    maxHeightEdit.setText(String.valueOf(mFlexItem.maxHeight));
    maxHeightEdit.addTextChangedListener(new FlexEditTextWatcher(maxHeightInput, new FixedDimensionInputValidator(), R.string.must_be_non_negative_integer));
    setNextFocusesOnEnterDown(orderEdit, flexGrowEdit, flexShrinkEdit, flexBasisPercentEdit, widthEdit, heightEdit, minWidthEdit, minHeightEdit, maxWidthEdit, maxHeightEdit);
    Spinner alignSelfSpinner = (Spinner) view.findViewById(R.id.spinner_align_self);
    ArrayAdapter<CharSequence> arrayAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.array_align_self, R.layout.spinner_item);
    alignSelfSpinner.setAdapter(arrayAdapter);
    alignSelfSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            String selected = parent.getItemAtPosition(position).toString();
            if (selected.equals(ALIGN_SELF_AUTO)) {
                mFlexItem.alignSelf = FlexboxLayout.LayoutParams.ALIGN_SELF_AUTO;
            } else if (selected.equals(ALIGN_SELF_FLEX_START)) {
                mFlexItem.alignSelf = FlexboxLayout.LayoutParams.ALIGN_SELF_FLEX_START;
            } else if (selected.equals(ALIGN_SELF_FLEX_END)) {
                mFlexItem.alignSelf = FlexboxLayout.LayoutParams.ALIGN_SELF_FLEX_END;
            } else if (selected.equals(ALIGN_SELF_CENTER)) {
                mFlexItem.alignSelf = FlexboxLayout.LayoutParams.ALIGN_SELF_CENTER;
            } else if (selected.equals(ALIGN_SELF_BASELINE)) {
                mFlexItem.alignSelf = FlexboxLayout.LayoutParams.ALIGN_SELF_BASELINE;
            } else if (selected.equals(ALIGN_SELF_STRETCH)) {
                mFlexItem.alignSelf = FlexboxLayout.LayoutParams.ALIGN_SELF_STRETCH;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        // No op
        }
    });
    CheckBox wrapBeforeCheckBox = (CheckBox) view.findViewById(R.id.checkbox_wrap_before);
    wrapBeforeCheckBox.setChecked(mFlexItem.wrapBefore);
    wrapBeforeCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mFlexItem.wrapBefore = isChecked;
        }
    });
    int alignSelfPosition = arrayAdapter.getPosition(alignSelfAsString(mFlexItem.alignSelf));
    alignSelfSpinner.setSelection(alignSelfPosition);
    view.findViewById(R.id.button_cancel).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    final Button okButton = (Button) view.findViewById(R.id.button_ok);
    okButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (orderTextInput.isErrorEnabled() || flexGrowInput.isErrorEnabled() || flexBasisPercentInput.isErrorEnabled() || widthInput.isErrorEnabled() || heightInput.isErrorEnabled() || minWidthInput.isErrorEnabled() || minHeightInput.isErrorEnabled() || maxWidthInput.isErrorEnabled() || maxHeightInput.isErrorEnabled()) {
                Toast.makeText(getActivity(), R.string.invalid_values_exist, Toast.LENGTH_SHORT).show();
                return;
            }
            if (mFlexItemChangedListener != null) {
                mFlexItemChangedListener.onFlexItemChanged(mFlexItem);
            }
            dismiss();
        }
    });
    return view;
}
Also used : DimensionInputValidator(com.google.android.apps.flexbox.validators.DimensionInputValidator) FixedDimensionInputValidator(com.google.android.apps.flexbox.validators.FixedDimensionInputValidator) FixedDimensionInputValidator(com.google.android.apps.flexbox.validators.FixedDimensionInputValidator) Spinner(android.widget.Spinner) IntegerInputValidator(com.google.android.apps.flexbox.validators.IntegerInputValidator) NonNegativeDecimalInputValidator(com.google.android.apps.flexbox.validators.NonNegativeDecimalInputValidator) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) TextInputLayout(android.support.design.widget.TextInputLayout) EditText(android.widget.EditText) FlexBasisPercentInputValidator(com.google.android.apps.flexbox.validators.FlexBasisPercentInputValidator) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) CheckBox(android.widget.CheckBox) AdapterView(android.widget.AdapterView) CompoundButton(android.widget.CompoundButton) Nullable(android.support.annotation.Nullable)

Example 37 with AdapterView

use of android.widget.AdapterView in project picasso by square.

the class PicassoSampleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.setContentView(R.layout.picasso_sample_activity);
    sampleContent = (FrameLayout) findViewById(R.id.sample_content);
    final ListView activityList = (ListView) findViewById(R.id.activity_list);
    final PicassoSampleAdapter adapter = new PicassoSampleAdapter(this);
    activityList.setAdapter(adapter);
    activityList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
            adapter.getItem(position).launch(PicassoSampleActivity.this);
        }
    });
    showHide = (ToggleButton) findViewById(R.id.faux_action_bar_control);
    showHide.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
            activityList.setVisibility(checked ? VISIBLE : GONE);
        }
    });
}
Also used : ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) CompoundButton(android.widget.CompoundButton)

Example 38 with AdapterView

use of android.widget.AdapterView in project LiveSDK-for-Android by liveservices.

the class ContactsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.view_contacts);
    ListView lv = getListView();
    lv.setTextFilterEnabled(true);
    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Contact contact = (Contact) parent.getItemAtPosition(position);
            ViewContactDialog dialog = new ViewContactDialog(ContactsActivity.this, contact);
            dialog.setOwnerActivity(ContactsActivity.this);
            dialog.show();
        }
    });
    LinearLayout layout = new LinearLayout(this);
    Button newCalendarButton = new Button(this);
    newCalendarButton.setText("New Contact");
    newCalendarButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            CreateContactDialog dialog = new CreateContactDialog(ContactsActivity.this);
            dialog.setOwnerActivity(ContactsActivity.this);
            dialog.show();
        }
    });
    layout.addView(newCalendarButton);
    lv.addHeaderView(layout);
    mAdapter = new ContactsListAdapter(this);
    setListAdapter(mAdapter);
    LiveSdkSampleApplication app = (LiveSdkSampleApplication) getApplication();
    mClient = app.getConnectClient();
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) ListView(android.widget.ListView) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) LiveSdkSampleApplication(com.microsoft.live.sample.LiveSdkSampleApplication) LinearLayout(android.widget.LinearLayout)

Example 39 with AdapterView

use of android.widget.AdapterView in project LiveSDK-for-Android by liveservices.

the class SkyDriveActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.skydrive);
    mPrevFolderIds = new Stack<String>();
    ListView lv = getListView();
    lv.setTextFilterEnabled(true);
    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            SkyDriveObject skyDriveObj = (SkyDriveObject) parent.getItemAtPosition(position);
            skyDriveObj.accept(new Visitor() {

                @Override
                public void visit(SkyDriveAlbum album) {
                    mPrevFolderIds.push(mCurrentFolderId);
                    loadFolder(album.getId());
                }

                @Override
                public void visit(SkyDrivePhoto photo) {
                    ViewPhotoDialog dialog = new ViewPhotoDialog(SkyDriveActivity.this, photo);
                    dialog.setOwnerActivity(SkyDriveActivity.this);
                    dialog.show();
                }

                @Override
                public void visit(SkyDriveFolder folder) {
                    mPrevFolderIds.push(mCurrentFolderId);
                    loadFolder(folder.getId());
                }

                @Override
                public void visit(SkyDriveFile file) {
                    Bundle b = new Bundle();
                    b.putString(JsonKeys.ID, file.getId());
                    b.putString(JsonKeys.NAME, file.getName());
                    showDialog(DIALOG_DOWNLOAD_ID, b);
                }

                @Override
                public void visit(SkyDriveVideo video) {
                    PlayVideoDialog dialog = new PlayVideoDialog(SkyDriveActivity.this, video);
                    dialog.setOwnerActivity(SkyDriveActivity.this);
                    dialog.show();
                }

                @Override
                public void visit(SkyDriveAudio audio) {
                    PlayAudioDialog audioDialog = new PlayAudioDialog(SkyDriveActivity.this, audio);
                    audioDialog.show();
                }
            });
        }
    });
    LinearLayout layout = new LinearLayout(this);
    Button newFolderButton = new Button(this);
    newFolderButton.setText("New Folder");
    newFolderButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            NewFolderDialog dialog = new NewFolderDialog(SkyDriveActivity.this);
            dialog.setOwnerActivity(SkyDriveActivity.this);
            dialog.show();
        }
    });
    layout.addView(newFolderButton);
    Button uploadFileButton = new Button(this);
    uploadFileButton.setText("Upload File");
    uploadFileButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getApplicationContext(), FilePicker.class);
            startActivityForResult(intent, FilePicker.PICK_FILE_REQUEST);
        }
    });
    layout.addView(uploadFileButton);
    lv.addHeaderView(layout);
    mPhotoAdapter = new SkyDriveListAdapter(this);
    setListAdapter(mPhotoAdapter);
    LiveSdkSampleApplication app = (LiveSdkSampleApplication) getApplication();
    mClient = app.getConnectClient();
}
Also used : Visitor(com.microsoft.live.sample.skydrive.SkyDriveObject.Visitor) ListView(android.widget.ListView) Button(android.widget.Button) LiveSdkSampleApplication(com.microsoft.live.sample.LiveSdkSampleApplication) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Bundle(android.os.Bundle) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) VideoView(android.widget.VideoView) OnClickListener(android.view.View.OnClickListener) LinearLayout(android.widget.LinearLayout) FilePicker(com.microsoft.live.sample.util.FilePicker)

Example 40 with AdapterView

use of android.widget.AdapterView in project MultiImageSelector by lovetuzitong.

the class MultiImageSelectorFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final int mode = selectMode();
    if (mode == MODE_MULTI) {
        ArrayList<String> tmp = getArguments().getStringArrayList(EXTRA_DEFAULT_SELECTED_LIST);
        if (tmp != null && tmp.size() > 0) {
            resultList = tmp;
        }
    }
    mImageAdapter = new ImageGridAdapter(getActivity(), showCamera(), 3);
    mImageAdapter.showSelectIndicator(mode == MODE_MULTI);
    mPopupAnchorView = view.findViewById(R.id.footer);
    mCategoryText = (TextView) view.findViewById(R.id.category_btn);
    mCategoryText.setText(R.string.mis_folder_all);
    mCategoryText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (mFolderPopupWindow == null) {
                createPopupFolderList();
            }
            if (mFolderPopupWindow.isShowing()) {
                mFolderPopupWindow.dismiss();
            } else {
                mFolderPopupWindow.show();
                int index = mFolderAdapter.getSelectIndex();
                index = index == 0 ? index : index - 1;
                mFolderPopupWindow.getListView().setSelection(index);
            }
        }
    });
    mGridView = (GridView) view.findViewById(R.id.grid);
    mGridView.setAdapter(mImageAdapter);
    mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (mImageAdapter.isShowCamera()) {
                if (i == 0) {
                    showCameraAction();
                } else {
                    Image image = (Image) adapterView.getAdapter().getItem(i);
                    selectImageFromGrid(image, mode);
                }
            } else {
                Image image = (Image) adapterView.getAdapter().getItem(i);
                selectImageFromGrid(image, mode);
            }
        }
    });
    mGridView.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            if (scrollState == SCROLL_STATE_FLING) {
                Picasso.with(view.getContext()).pauseTag(TAG);
            } else {
                Picasso.with(view.getContext()).resumeTag(TAG);
            }
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
        }
    });
    mFolderAdapter = new FolderAdapter(getActivity());
}
Also used : ImageGridAdapter(me.nereo.multi_image_selector.adapter.ImageGridAdapter) AbsListView(android.widget.AbsListView) Image(me.nereo.multi_image_selector.bean.Image) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) Point(android.graphics.Point) FolderAdapter(me.nereo.multi_image_selector.adapter.FolderAdapter) AdapterView(android.widget.AdapterView)

Aggregations

AdapterView (android.widget.AdapterView)677 View (android.view.View)653 ListView (android.widget.ListView)412 TextView (android.widget.TextView)342 Intent (android.content.Intent)177 ImageView (android.widget.ImageView)174 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)142 ArrayAdapter (android.widget.ArrayAdapter)75 ArrayList (java.util.ArrayList)71 ViewGroup (android.view.ViewGroup)63 AbsListView (android.widget.AbsListView)59 GridView (android.widget.GridView)58 Bundle (android.os.Bundle)53 Spinner (android.widget.Spinner)50 LinearLayout (android.widget.LinearLayout)49 OnClickListener (android.view.View.OnClickListener)46 RecyclerView (android.support.v7.widget.RecyclerView)42 DialogInterface (android.content.DialogInterface)41 SuppressLint (android.annotation.SuppressLint)38 LayoutInflater (android.view.LayoutInflater)34