Search in sources :

Example 6 with AppCompatSpinner

use of android.support.v7.widget.AppCompatSpinner in project AnExplorer by 1hakr.

the class CreateConnectionFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context context = getActivity();
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    final LayoutInflater dialogInflater = getActivity().getLayoutInflater();
    final View view = dialogInflater.inflate(R.layout.dialog_create_connection, null, false);
    name = (AppCompatEditText) view.findViewById(R.id.name);
    host = (AppCompatEditText) view.findViewById(R.id.host);
    port = (AppCompatEditText) view.findViewById(R.id.port);
    path = (AppCompatEditText) view.findViewById(R.id.path);
    hostContainer = view.findViewById(R.id.hostContainer);
    pathContainer = view.findViewById(R.id.pathContainer);
    username = (AppCompatEditText) view.findViewById(R.id.username);
    usernameContainer = view.findViewById(R.id.usernameContainer);
    password = (AppCompatEditText) view.findViewById(R.id.password);
    passwordContainer = view.findViewById(R.id.passwordContainer);
    scheme = (AppCompatSpinner) view.findViewById(R.id.scheme);
    anonymous = (AppCompatCheckBox) view.findViewById(R.id.anonymous);
    anonymous.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            usernameContainer.setVisibility(b ? View.GONE : View.VISIBLE);
            passwordContainer.setVisibility(b ? View.GONE : View.VISIBLE);
        }
    });
    if (connection_id != 0) {
        NetworkConnection connection = NetworkConnection.fromConnectionId(getActivity(), connection_id);
        ArrayAdapter myAdap = (ArrayAdapter) scheme.getAdapter();
        int spinnerPosition = myAdap.getPosition(connection.getScheme().toUpperCase());
        scheme.setSelection(spinnerPosition);
        name.setText(connection.getName());
        host.setText(connection.getHost());
        port.setText(Integer.toString(connection.getPort()));
        path.setText(connection.getPath());
        username.setText(connection.getUserName());
        password.setText(connection.getPassword());
        anonymous.setChecked(connection.isAnonymousLogin());
        if (SERVER.equals(connection.getType())) {
            hostContainer.setVisibility(View.GONE);
            pathContainer.setVisibility(View.VISIBLE);
        }
    }
    builder.setTitle((connection_id == 0 ? "New" : "Edit") + " Connection");
    builder.setView(view);
    builder.setPositiveButton(connection_id == 0 ? "ADD" : "SAVE", new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            final BaseActivity activity = (BaseActivity) getActivity();
            NetworkConnection networkConnection = getNetworkConnection();
            if (validate(networkConnection)) {
                new CreateConnectionTask(activity, networkConnection).executeOnExecutor(ProviderExecutor.forAuthority(ExplorerProvider.AUTHORITY));
            }
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    return builder.create();
}
Also used : Context(android.content.Context) AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) NetworkConnection(dev.dworks.apps.anexplorer.network.NetworkConnection) View(android.view.View) LayoutInflater(android.view.LayoutInflater) BaseActivity(dev.dworks.apps.anexplorer.BaseActivity) OnClickListener(android.content.DialogInterface.OnClickListener) CompoundButton(android.widget.CompoundButton) ArrayAdapter(android.widget.ArrayAdapter)

Example 7 with AppCompatSpinner

use of android.support.v7.widget.AppCompatSpinner in project Reader by TheKeeperOfPie.

the class FragmentInbox method onCreateView.

@SuppressWarnings("ResourceType")
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_inbox, container, false);
    listener = new ControllerInbox.Listener() {

        @Override
        public void setPage(Page page) {
            spinnerPage.setSelection(adapterInboxPage.getPages().indexOf(page));
        }

        @Override
        public RecyclerView.Adapter getAdapter() {
            return adapterInbox;
        }

        @Override
        public void setToolbarTitle(CharSequence title) {
            toolbar.setTitle(title);
        }

        @Override
        public void setRefreshing(boolean refreshing) {
            swipeRefreshInbox.setRefreshing(refreshing);
        }

        @Override
        public void post(Runnable runnable) {
            recyclerInbox.post(runnable);
        }
    };
    layoutCoordinator = (CoordinatorLayout) view.findViewById(R.id.layout_coordinator);
    layoutAppBar = (AppBarLayout) view.findViewById(R.id.layout_app_bar);
    int styleColorBackground = AppSettings.THEME_DARK.equals(mListener.getThemeBackground()) ? R.style.MenuDark : R.style.MenuLight;
    ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(new ThemeWrapper(activity, UtilsColor.getThemeForColor(getResources(), themer.getColorPrimary(), mListener)), styleColorBackground);
    toolbar = (Toolbar) activity.getLayoutInflater().cloneInContext(contextThemeWrapper).inflate(R.layout.toolbar, layoutAppBar, false);
    layoutAppBar.addView(toolbar);
    ((AppBarLayout.LayoutParams) toolbar.getLayoutParams()).setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
    toolbar.setTitleTextColor(themer.getColorFilterPrimary().getColor());
    toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
    toolbar.getNavigationIcon().mutate().setColorFilter(themer.getColorFilterPrimary());
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mListener.openDrawer();
        }
    });
    setUpOptionsMenu();
    floatingActionButtonNewMessage = (FloatingActionButton) view.findViewById(R.id.fab_new_message);
    floatingActionButtonNewMessage.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            FragmentNewMessage fragmentNewMessage = FragmentNewMessage.newInstance();
            getFragmentManager().beginTransaction().hide(FragmentInbox.this).add(R.id.frame_fragment, fragmentNewMessage, FragmentNewMessage.TAG).addToBackStack(null).commit();
        }
    });
    floatingActionButtonNewMessage.setColorFilter(themer.getColorFilterAccent());
    behaviorFloatingActionButton = new ScrollAwareFloatingActionButtonBehavior(activity, null, new ScrollAwareFloatingActionButtonBehavior.OnVisibilityChangeListener() {

        @Override
        public void onStartHideFromScroll() {
        }

        @Override
        public void onEndHideFromScroll() {
        }
    });
    ((CoordinatorLayout.LayoutParams) floatingActionButtonNewMessage.getLayoutParams()).setBehavior(behaviorFloatingActionButton);
    adapterInboxPage = new AdapterInboxPage(activity);
    spinnerPage = new AppCompatSpinner(contextThemeWrapper);
    toolbar.addView(spinnerPage);
    ((Toolbar.LayoutParams) spinnerPage.getLayoutParams()).setMarginEnd((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()));
    spinnerPage.setAdapter(adapterInboxPage);
    spinnerPage.setSelection(adapterInboxPage.getPages().indexOf(controllerInbox.getPage()));
    spinnerPage.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            controllerInbox.setPage(adapterInboxPage.getItem(position));
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    swipeRefreshInbox = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_inbox);
    swipeRefreshInbox.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            controllerInbox.reload();
        }
    });
    linearLayoutManager = new LinearLayoutManager(activity);
    recyclerInbox = (RecyclerView) view.findViewById(R.id.recycler_inbox);
    recyclerInbox.setHasFixedSize(true);
    recyclerInbox.setItemAnimator(new DefaultItemAnimator());
    recyclerInbox.getItemAnimator().setRemoveDuration(UtilsAnimation.EXPAND_ACTION_DURATION);
    recyclerInbox.setLayoutManager(linearLayoutManager);
    recyclerInbox.addItemDecoration(new ItemDecorationDivider(activity, ItemDecorationDivider.VERTICAL_LIST));
    AdapterListener adapterListener = new AdapterListener() {

        @Override
        public void scrollAndCenter(int position, int height) {
            linearLayoutManager.scrollToPositionWithOffset(position, 0);
        }

        @Override
        public void hideToolbar() {
            AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
            behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
        }

        @Override
        public void clearDecoration() {
            behaviorFloatingActionButton.animateOut(floatingActionButtonNewMessage);
            AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
            behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
        }

        @Override
        public void requestMore() {
            controllerInbox.loadMore();
        }

        @Override
        public void requestDisallowInterceptTouchEventVertical(boolean disallow) {
            recyclerInbox.requestDisallowInterceptTouchEvent(disallow);
            swipeRefreshInbox.requestDisallowInterceptTouchEvent(disallow);
        }

        @Override
        public void requestDisallowInterceptTouchEventHorizontal(boolean disallow) {
        }
    };
    AdapterCommentList.ViewHolderComment.Listener listenerComments = new AdapterCommentList.ViewHolderComment.Listener() {

        @Override
        public void onToggleComment(Comment comment) {
        }

        @Override
        public void onShowReplyEditor(Comment comment) {
        }

        @Override
        public void onEditComment(Comment comment, String text) {
        }

        @Override
        public void onSendComment(Comment comment, String text) {
        }

        @Override
        public void onMarkRead(Comment comment) {
        }

        @Override
        public void onLoadNestedComments(Comment comment) {
        }

        @Override
        public void onJumpToParent(Comment comment) {
        }

        @Override
        public void onViewProfile(Comment comment) {
        }

        @Override
        public void onCopyText(Comment comment) {
        }

        @Override
        public void onDeleteComment(Comment comment) {
        }

        @Override
        public void onReport(Comment comment) {
        }

        @Override
        public void onVoteComment(Comment comment, AdapterCommentList.ViewHolderComment viewHolderComment, Likes vote) {
        }

        @Override
        public void onSave(Comment comment) {
        }
    };
    if (adapterInbox == null) {
        adapterInbox = new AdapterInbox(controllerInbox, controllerUser, adapterListener, listenerComments, mListener.getEventListenerBase());
    }
    recyclerInbox.setAdapter(adapterInbox);
    return view;
}
Also used : ItemDecorationDivider(com.winsonchiu.reader.utils.ItemDecorationDivider) AdapterListener(com.winsonchiu.reader.adapter.AdapterListener) Page(com.winsonchiu.reader.data.Page) FragmentNewMessage(com.winsonchiu.reader.FragmentNewMessage) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) ContextThemeWrapper(android.view.ContextThemeWrapper) ThemeWrapper(com.winsonchiu.reader.theme.ThemeWrapper) AdapterCommentList(com.winsonchiu.reader.comments.AdapterCommentList) ScrollAwareFloatingActionButtonBehavior(com.winsonchiu.reader.utils.ScrollAwareFloatingActionButtonBehavior) AppBarLayout(android.support.design.widget.AppBarLayout) ScrollAwareFloatingActionButtonBehavior(com.winsonchiu.reader.utils.ScrollAwareFloatingActionButtonBehavior) Comment(com.winsonchiu.reader.data.reddit.Comment) AdapterListener(com.winsonchiu.reader.adapter.AdapterListener) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) AppCompatSpinner(android.support.v7.widget.AppCompatSpinner) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) ContextThemeWrapper(android.view.ContextThemeWrapper) AdapterView(android.widget.AdapterView) Likes(com.winsonchiu.reader.data.reddit.Likes)

Example 8 with AppCompatSpinner

use of android.support.v7.widget.AppCompatSpinner in project GeometricWeather by WangDaYeeeeee.

the class CreateWidgetClockDayVerticalActivity method initWidget.

@Override
public void initWidget() {
    setWidgetView(true);
    ImageView wallpaper = findViewById(R.id.activity_create_widget_clock_day_vertical_wall);
    bindWallpaper(wallpaper);
    this.container = findViewById(R.id.activity_create_widget_clock_day_vertical_container);
    AppCompatSpinner viewTypeSpinner = findViewById(R.id.activity_create_widget_clock_day_vertical_styleSpinner);
    viewTypeSpinner.setOnItemSelectedListener(new ViewTypeSpinnerSelectedListener());
    viewTypeSpinner.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, viewTypes));
    this.showCardSwitch = findViewById(R.id.activity_create_widget_clock_day_vertical_showCardSwitch);
    showCardSwitch.setOnCheckedChangeListener(new ShowCardSwitchCheckListener());
    this.hideSubtitleSwitch = findViewById(R.id.activity_create_widget_clock_day_vertical_hideSubtitleSwitch);
    hideSubtitleSwitch.setOnCheckedChangeListener(new HideSubtitleSwitchCheckListener());
    AppCompatSpinner subtitleDataSpinner = findViewById(R.id.activity_create_widget_clock_day_vertical_subtitleDataSpinner);
    subtitleDataSpinner.setOnItemSelectedListener(new SubtitleDataSpinnerSelectedListener());
    subtitleDataSpinner.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, subtitleData));
    this.blackTextSwitch = findViewById(R.id.activity_create_widget_clock_day_vertical_blackTextSwitch);
    blackTextSwitch.setOnCheckedChangeListener(new BlackTextSwitchCheckListener());
    Button doneButton = findViewById(R.id.activity_create_widget_clock_day_vertical_doneButton);
    doneButton.setOnClickListener(this);
}
Also used : Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) ImageView(android.widget.ImageView) AppCompatSpinner(android.support.v7.widget.AppCompatSpinner)

Example 9 with AppCompatSpinner

use of android.support.v7.widget.AppCompatSpinner in project GeometricWeather by WangDaYeeeeee.

the class CreateWidgetDayActivity method initWidget.

@Override
public void initWidget() {
    setWidgetView(true);
    ImageView wallpaper = findViewById(R.id.activity_create_widget_day_wall);
    bindWallpaper(wallpaper);
    this.container = findViewById(R.id.activity_create_widget_day_container);
    AppCompatSpinner viewTypeSpinner = findViewById(R.id.activity_create_widget_day_styleSpinner);
    viewTypeSpinner.setOnItemSelectedListener(new ViewTypeSpinnerSelectedListener());
    viewTypeSpinner.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, viewTypes));
    this.showCardSwitch = findViewById(R.id.activity_create_widget_day_showCardSwitch);
    showCardSwitch.setOnCheckedChangeListener(new ShowCardSwitchCheckListener());
    this.hideSubtitleSwitch = findViewById(R.id.activity_create_widget_day_hideSubtitleSwitch);
    hideSubtitleSwitch.setOnCheckedChangeListener(new HideRefreshTimeSwitchCheckListener());
    AppCompatSpinner subtitleDataSpinner = findViewById(R.id.activity_create_widget_day_subtitleDataSpinner);
    subtitleDataSpinner.setOnItemSelectedListener(new SubtitleDataSpinnerSelectedListener());
    subtitleDataSpinner.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, subtitleData));
    this.blackTextSwitch = findViewById(R.id.activity_create_widget_day_blackTextSwitch);
    blackTextSwitch.setOnCheckedChangeListener(new BlackTextSwitchCheckListener());
    Button doneButton = findViewById(R.id.activity_create_widget_day_doneButton);
    doneButton.setOnClickListener(this);
}
Also used : Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) ImageView(android.widget.ImageView) AppCompatSpinner(android.support.v7.widget.AppCompatSpinner)

Example 10 with AppCompatSpinner

use of android.support.v7.widget.AppCompatSpinner in project GeometricWeather by WangDaYeeeeee.

the class CreateWidgetDayWeekActivity method initWidget.

@Override
public void initWidget() {
    setWidgetView(true);
    ImageView wallpaper = findViewById(R.id.activity_create_widget_day_week_wall);
    bindWallpaper(wallpaper);
    this.container = findViewById(R.id.activity_create_widget_day_week_container);
    AppCompatSpinner viewTypeSpinner = findViewById(R.id.activity_create_widget_day_week_styleSpinner);
    viewTypeSpinner.setOnItemSelectedListener(new ViewTypeSpinnerSelectedListener());
    viewTypeSpinner.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, viewTypes));
    this.showCardSwitch = findViewById(R.id.activity_create_widget_day_week_showCardSwitch);
    showCardSwitch.setOnCheckedChangeListener(new ShowCardSwitchCheckListener());
    this.hideSubtitleSwitch = findViewById(R.id.activity_create_widget_day_week_hideSubtitleSwitch);
    hideSubtitleSwitch.setOnCheckedChangeListener(new HideRefreshTimeSwitchCheckListener());
    AppCompatSpinner subtitleDataSpinner = findViewById(R.id.activity_create_widget_day_week_subtitleDataSpinner);
    subtitleDataSpinner.setOnItemSelectedListener(new SubtitleDataSpinnerSelectedListener());
    subtitleDataSpinner.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, subtitleData));
    this.blackTextSwitch = findViewById(R.id.activity_create_widget_day_week_blackTextSwitch);
    blackTextSwitch.setOnCheckedChangeListener(new BlackTextSwitchCheckListener());
    Button doneButton = findViewById(R.id.activity_create_widget_day_week_doneButton);
    doneButton.setOnClickListener(this);
}
Also used : Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) ImageView(android.widget.ImageView) AppCompatSpinner(android.support.v7.widget.AppCompatSpinner)

Aggregations

AppCompatSpinner (android.support.v7.widget.AppCompatSpinner)8 View (android.view.View)6 CompoundButton (android.widget.CompoundButton)4 ImageView (android.widget.ImageView)4 RecyclerView (android.support.v7.widget.RecyclerView)3 AdapterView (android.widget.AdapterView)3 Button (android.widget.Button)3 Context (android.content.Context)2 AppBarLayout (android.support.design.widget.AppBarLayout)2 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)2 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)2 AppCompatButton (android.support.v7.widget.AppCompatButton)2 AppCompatImageView (android.support.v7.widget.AppCompatImageView)2 AppCompatTextView (android.support.v7.widget.AppCompatTextView)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 ContextThemeWrapper (android.view.ContextThemeWrapper)2 ArrayAdapter (android.widget.ArrayAdapter)2 AdapterListener (com.winsonchiu.reader.adapter.AdapterListener)2 AdapterCommentList (com.winsonchiu.reader.comments.AdapterCommentList)2 Page (com.winsonchiu.reader.data.Page)2