Search in sources :

Example 36 with DOWN

use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project android by owncloud.

the class UploadFilesActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    Log_OC.d(TAG, "onCreate() start");
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        mCurrentDir = new File(savedInstanceState.getString(UploadFilesActivity.KEY_DIRECTORY_PATH));
    } else {
        mCurrentDir = Environment.getExternalStorageDirectory();
    }
    mAccountOnCreation = getAccount();
    /// USER INTERFACE
    // Drop-down navigation 
    mDirectories = new CustomArrayAdapter<String>(this, R.layout.support_simple_spinner_dropdown_item);
    File currDir = mCurrentDir;
    while (currDir != null && currDir.getParentFile() != null) {
        mDirectories.add(currDir.getName());
        currDir = currDir.getParentFile();
    }
    mDirectories.add(File.separator);
    // Inflate and set the layout view
    setContentView(R.layout.upload_files_layout);
    mFileListFragment = (LocalFileListFragment) getSupportFragmentManager().findFragmentById(R.id.local_files_list);
    // Set input controllers
    mCancelBtn = (Button) findViewById(R.id.upload_files_btn_cancel);
    mCancelBtn.setOnClickListener(this);
    mUploadBtn = (Button) findViewById(R.id.upload_files_btn_upload);
    mUploadBtn.setOnClickListener(this);
    SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    Integer localBehaviour = appPreferences.getInt("prefs_uploader_behaviour", FileUploader.LOCAL_BEHAVIOUR_COPY);
    mRadioBtnMoveFiles = (RadioButton) findViewById(R.id.upload_radio_move);
    if (localBehaviour == FileUploader.LOCAL_BEHAVIOUR_MOVE) {
        mRadioBtnMoveFiles.setChecked(true);
    }
    mRadioBtnCopyFiles = (RadioButton) findViewById(R.id.upload_radio_copy);
    if (localBehaviour == FileUploader.LOCAL_BEHAVIOUR_COPY) {
        mRadioBtnCopyFiles.setChecked(true);
    }
    // setup the toolbar
    setupToolbar();
    // Action bar setup
    ActionBar actionBar = getSupportActionBar();
    // mandatory since Android ICS, according to the
    actionBar.setHomeButtonEnabled(true);
    // official documentation
    actionBar.setDisplayHomeAsUpEnabled(mCurrentDir != null && mCurrentDir.getName() != null);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setListNavigationCallbacks(mDirectories, this);
    // wait dialog
    if (mCurrentDialog != null) {
        mCurrentDialog.dismiss();
        mCurrentDialog = null;
    }
    Log_OC.d(TAG, "onCreate() end");
}
Also used : SharedPreferences(android.content.SharedPreferences) File(java.io.File) ActionBar(android.support.v7.app.ActionBar)

Example 37 with DOWN

use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project Rutgers-Course-Tracker by tevjef.

the class TrackedSectionsFragment method initRecyclerView.

public void initRecyclerView() {
    LinearLayoutManager layoutManager = new LinearLayoutManager(getParentActivity());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    layoutManager.setSmoothScrollbarEnabled(true);
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.setHasFixedSize(true);
    RecyclerSimpleScrollListener recyclerSimpleScrollListener = new RecyclerSimpleScrollListener();
    mRecyclerView.addOnScrollListener(recyclerSimpleScrollListener);
    recyclerSimpleScrollListener.getDirectionObservable().subscribe(new Action1<RecyclerSimpleScrollListener.Direction>() {

        @Override
        public void call(RecyclerSimpleScrollListener.Direction direction) {
            switch(direction) {
                case UP:
                    animateFabIn();
                    //mFab.show();
                    break;
                case DOWN:
                    animateFabOut();
                    //mFab.hide();
                    break;
                case NEUTRAL:
                    break;
            }
        }

        //The animation up and down takes into account if he snackbar is showing or not.
        private void animateFabIn() {
            ViewCompat.animate(mFab).alpha(1).setStartDelay(50).start();
            ViewCompat.animate(mFab).translationY(mViewState.snackBarShowing ? -SnackbarManager.getCurrentSnackbar().getHeight() : 0).setStartDelay(50).start();
        }

        private void animateFabOut() {
            ViewCompat.animate(mFab).alphaBy(0).setStartDelay(50).start();
            ViewCompat.animate(mFab).translationYBy(250).setStartDelay(50).start();
        }
    });
    if (mListDataset == null) {
        mListDataset = new ArrayList<>(10);
    }
    if (mRecyclerView.getAdapter() == null) {
        mRecyclerView.setAdapter(new TrackedSectionsFragmentAdapter(mListDataset, this));
    }
}
Also used : RecyclerSimpleScrollListener(com.tevinjeffrey.rutgersct.ui.utils.RecyclerSimpleScrollListener) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 38 with DOWN

use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project plaid by nickbutcher.

the class HomeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    ButterKnife.bind(this);
    drawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    setActionBar(toolbar);
    if (savedInstanceState == null) {
        animateToolbar();
    }
    setExitSharedElementCallback(FeedAdapter.createSharedElementReenterCallback(this));
    dribbblePrefs = DribbblePrefs.get(this);
    designerNewsPrefs = DesignerNewsPrefs.get(this);
    filtersAdapter = new FilterAdapter(this, SourceManager.getSources(this), new FilterAdapter.FilterAuthoriser() {

        @Override
        public void requestDribbbleAuthorisation(View sharedElement, Source forSource) {
            Intent login = new Intent(HomeActivity.this, DribbbleLogin.class);
            MorphTransform.addExtras(login, ContextCompat.getColor(HomeActivity.this, R.color.background_dark), sharedElement.getHeight() / 2);
            ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(HomeActivity.this, sharedElement, getString(R.string.transition_dribbble_login));
            startActivityForResult(login, getAuthSourceRequestCode(forSource), options.toBundle());
        }
    });
    dataManager = new DataManager(this, filtersAdapter) {

        @Override
        public void onDataLoaded(List<? extends PlaidItem> data) {
            adapter.addAndResort(data);
            checkEmptyState();
        }
    };
    adapter = new FeedAdapter(this, dataManager, columns, PocketUtils.isPocketInstalled(this));
    grid.setAdapter(adapter);
    layoutManager = new GridLayoutManager(this, columns);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            return adapter.getItemColumnSpan(position);
        }
    });
    grid.setLayoutManager(layoutManager);
    grid.addOnScrollListener(toolbarElevation);
    grid.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) {

        @Override
        public void onLoadMore() {
            dataManager.loadAllDataSources();
        }
    });
    grid.setHasFixedSize(true);
    grid.addItemDecoration(new GridItemDividerDecoration(adapter.getDividedViewHolderClasses(), this, R.dimen.divider_height, R.color.divider));
    grid.setItemAnimator(new HomeGridItemAnimator());
    // drawer layout treats fitsSystemWindows specially so we have to handle insets ourselves
    drawer.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {

        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            // inset the toolbar down by the status bar height
            ViewGroup.MarginLayoutParams lpToolbar = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
            lpToolbar.topMargin += insets.getSystemWindowInsetTop();
            lpToolbar.leftMargin += insets.getSystemWindowInsetLeft();
            lpToolbar.rightMargin += insets.getSystemWindowInsetRight();
            toolbar.setLayoutParams(lpToolbar);
            // inset the grid top by statusbar+toolbar & the bottom by the navbar (don't clip)
            grid.setPadding(// landscape
            grid.getPaddingLeft() + insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop() + ViewUtils.getActionBarSize(HomeActivity.this), // landscape
            grid.getPaddingRight() + insets.getSystemWindowInsetRight(), grid.getPaddingBottom() + insets.getSystemWindowInsetBottom());
            // inset the fab for the navbar
            ViewGroup.MarginLayoutParams lpFab = (ViewGroup.MarginLayoutParams) fab.getLayoutParams();
            // portrait
            lpFab.bottomMargin += insets.getSystemWindowInsetBottom();
            // landscape
            lpFab.rightMargin += insets.getSystemWindowInsetRight();
            fab.setLayoutParams(lpFab);
            View postingStub = findViewById(R.id.stub_posting_progress);
            ViewGroup.MarginLayoutParams lpPosting = (ViewGroup.MarginLayoutParams) postingStub.getLayoutParams();
            // portrait
            lpPosting.bottomMargin += insets.getSystemWindowInsetBottom();
            // landscape
            lpPosting.rightMargin += insets.getSystemWindowInsetRight();
            postingStub.setLayoutParams(lpPosting);
            // we place a background behind the status bar to combine with it's semi-transparent
            // color to get the desired appearance.  Set it's height to the status bar height
            View statusBarBackground = findViewById(R.id.status_bar_background);
            FrameLayout.LayoutParams lpStatus = (FrameLayout.LayoutParams) statusBarBackground.getLayoutParams();
            lpStatus.height = insets.getSystemWindowInsetTop();
            statusBarBackground.setLayoutParams(lpStatus);
            // inset the filters list for the status bar / navbar
            // need to set the padding end for landscape case
            final boolean ltr = filtersList.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;
            filtersList.setPaddingRelative(filtersList.getPaddingStart(), filtersList.getPaddingTop() + insets.getSystemWindowInsetTop(), filtersList.getPaddingEnd() + (ltr ? insets.getSystemWindowInsetRight() : 0), filtersList.getPaddingBottom() + insets.getSystemWindowInsetBottom());
            // clear this listener so insets aren't re-applied
            drawer.setOnApplyWindowInsetsListener(null);
            return insets.consumeSystemWindowInsets();
        }
    });
    setupTaskDescription();
    filtersList.setAdapter(filtersAdapter);
    filtersList.setItemAnimator(new FilterAdapter.FilterAnimator());
    filtersAdapter.registerFilterChangedCallback(filtersChangedCallbacks);
    dataManager.loadAllDataSources();
    ItemTouchHelper.Callback callback = new FilterTouchHelperCallback(filtersAdapter);
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
    itemTouchHelper.attachToRecyclerView(filtersList);
    checkEmptyState();
}
Also used : FilterTouchHelperCallback(io.plaidapp.ui.recyclerview.FilterTouchHelperCallback) Source(io.plaidapp.data.Source) GridItemDividerDecoration(io.plaidapp.ui.recyclerview.GridItemDividerDecoration) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) WindowInsets(android.view.WindowInsets) ActivityOptions(android.app.ActivityOptions) ViewGroup(android.view.ViewGroup) Intent(android.content.Intent) DataManager(io.plaidapp.data.DataManager) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) GridLayoutManager(android.support.v7.widget.GridLayoutManager) FrameLayout(android.widget.FrameLayout) InfiniteScrollListener(io.plaidapp.ui.recyclerview.InfiniteScrollListener)

Example 39 with DOWN

use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project NewPipe by TeamNewPipe.

the class SearchInfoItemFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_searchinfoitem, container, false);
    Context context = view.getContext();
    loadingIndicator = (ProgressBar) view.findViewById(R.id.progressBar);
    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.list);
    streamInfoListLayoutManager = new LinearLayoutManager(context);
    recyclerView.setLayoutManager(streamInfoListLayoutManager);
    infoListAdapter = new InfoListAdapter(getActivity(), getActivity().findViewById(android.R.id.content));
    infoListAdapter.setFooter(inflater.inflate(R.layout.pignate_footer, recyclerView, false));
    infoListAdapter.showFooter(false);
    infoListAdapter.setOnStreamInfoItemSelectedListener(new InfoItemBuilder.OnInfoItemSelectedListener() {

        @Override
        public void selected(String url, int serviceId) {
            NavStack.getInstance().openDetailActivity(getContext(), url, serviceId);
        }
    });
    infoListAdapter.setOnChannelInfoItemSelectedListener(new InfoItemBuilder.OnInfoItemSelectedListener() {

        @Override
        public void selected(String url, int serviceId) {
            NavStack.getInstance().openChannelActivity(getContext(), url, serviceId);
        }
    });
    recyclerView.setAdapter(infoListAdapter);
    recyclerView.clearOnScrollListeners();
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            int pastVisiblesItems, visibleItemCount, totalItemCount;
            super.onScrolled(recyclerView, dx, dy);
            if (//check for scroll down
            dy > 0) {
                visibleItemCount = streamInfoListLayoutManager.getChildCount();
                totalItemCount = streamInfoListLayoutManager.getItemCount();
                pastVisiblesItems = streamInfoListLayoutManager.findFirstVisibleItemPosition();
                if ((visibleItemCount + pastVisiblesItems) >= totalItemCount && !isLoading) {
                    pageNumber++;
                    search(searchQuery, pageNumber);
                }
            }
        }
    });
    return view;
}
Also used : Context(android.content.Context) InfoItemBuilder(org.schabi.newpipe.info_list.InfoItemBuilder) RecyclerView(android.support.v7.widget.RecyclerView) InfoListAdapter(org.schabi.newpipe.info_list.InfoListAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SearchView(android.support.v7.widget.SearchView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 40 with DOWN

use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project LookLook by xinghongfei.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_layout);
    ButterKnife.bind(this);
    setSupportActionBar(toolbar);
    IMainPresenter = new MainPresenterImpl(this, this);
    IMainPresenter.getBackground();
    toolbar.setOnMenuItemClickListener(onMenuItemClick);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        animateToolbar();
    }
    addfragmentsAndTitle();
    //        setStatusColor();
    drawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    if (savedInstanceState == null) {
        nevigationId = SharePreferenceUtil.getNevigationItem(this);
        if (nevigationId != -1) {
            currentMenuItem = navView.getMenu().findItem(nevigationId);
        }
        if (currentMenuItem == null) {
            currentMenuItem = navView.getMenu().findItem(R.id.zhihuitem);
        }
        if (currentMenuItem != null) {
            currentMenuItem.setChecked(true);
            // TODO: 16/8/17 add a fragment and set toolbar title
            Fragment fragment = getFragmentById(currentMenuItem.getItemId());
            String title = mTitleArryMap.get((Integer) currentMenuItem.getItemId());
            if (fragment != null) {
                switchFragment(fragment, title);
            }
        }
    } else {
        if (currentMenuItem != null) {
            Fragment fragment = getFragmentById(currentMenuItem.getItemId());
            String title = mTitleArryMap.get((Integer) currentMenuItem.getItemId());
            if (fragment != null) {
                switchFragment(fragment, title);
            }
        } else {
            switchFragment(new ZhihuFragment(), " ");
            currentMenuItem = navView.getMenu().findItem(R.id.zhihuitem);
        }
    }
    navView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(MenuItem item) {
            if (currentMenuItem != item && currentMenuItem != null) {
                currentMenuItem.setChecked(false);
                int id = item.getItemId();
                SharePreferenceUtil.putNevigationItem(MainActivity.this, id);
                currentMenuItem = item;
                currentMenuItem.setChecked(true);
                switchFragment(getFragmentById(currentMenuItem.getItemId()), mTitleArryMap.get(currentMenuItem.getItemId()));
            }
            drawer.closeDrawer(GravityCompat.END, true);
            return true;
        }
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        drawer.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {

            @Override
            public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
                // inset the toolbar down by the status bar height
                ViewGroup.MarginLayoutParams lpToolbar = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
                lpToolbar.topMargin += insets.getSystemWindowInsetTop();
                lpToolbar.rightMargin += insets.getSystemWindowInsetRight();
                toolbar.setLayoutParams(lpToolbar);
                // inset the grid top by statusbar+toolbar & the bottom by the navbar (don't clip)
                mFragmentContainer.setPadding(mFragmentContainer.getPaddingLeft(), insets.getSystemWindowInsetTop() + ViewUtils.getActionBarSize(MainActivity.this), // landscape
                mFragmentContainer.getPaddingRight() + insets.getSystemWindowInsetRight(), mFragmentContainer.getPaddingBottom() + insets.getSystemWindowInsetBottom());
                // we place a background behind the status bar to combine with it's semi-transparent
                // color to get the desired appearance.  Set it's height to the status bar height
                View statusBarBackground = findViewById(R.id.status_bar_background);
                FrameLayout.LayoutParams lpStatus = (FrameLayout.LayoutParams) statusBarBackground.getLayoutParams();
                lpStatus.height = insets.getSystemWindowInsetTop();
                statusBarBackground.setLayoutParams(lpStatus);
                // inset the filters list for the status bar / navbar
                // need to set the padding end for landscape case
                // clear this listener so insets aren't re-applied
                drawer.setOnApplyWindowInsetsListener(null);
                return insets.consumeSystemWindowInsets();
            }
        });
    }
    int[][] state = new int[][] { // unchecked
    new int[] { -android.R.attr.state_checked }, // pressed
    new int[] { android.R.attr.state_checked } };
    int[] color = new int[] { Color.BLACK, Color.BLACK };
    int[] iconcolor = new int[] { Color.GRAY, Color.BLACK };
    navView.setItemTextColor(new ColorStateList(state, color));
    navView.setItemIconTintList(new ColorStateList(state, iconcolor));
    //主题变色
    MenuItem item = navView.getMenu().findItem(R.id.nav_theme);
    mThemeSwitch = (SwitchCompat) MenuItemCompat.getActionView(item).findViewById(R.id.view_switch);
    mThemeSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mThemeSwitch.setChecked(isChecked);
            if (isChecked) {
                setThemeColor(Color.GREEN);
            } else {
                setThemeColor(getResources().getColor(R.color.colorPrimaryDark));
            }
        }
    });
}
Also used : NavigationView(android.support.design.widget.NavigationView) ViewGroup(android.view.ViewGroup) ColorStateList(android.content.res.ColorStateList) MenuItem(android.view.MenuItem) MainPresenterImpl(com.looklook.xinghongfei.looklook.presenter.implPresenter.MainPresenterImpl) MeiziFragment(com.looklook.xinghongfei.looklook.fragment.MeiziFragment) ZhihuFragment(com.looklook.xinghongfei.looklook.fragment.ZhihuFragment) TopNewsFragment(com.looklook.xinghongfei.looklook.fragment.TopNewsFragment) Fragment(android.support.v4.app.Fragment) NavigationView(android.support.design.widget.NavigationView) BindView(butterknife.BindView) View(android.view.View) ActionMenuView(android.support.v7.widget.ActionMenuView) TextView(android.widget.TextView) WindowInsets(android.view.WindowInsets) FrameLayout(android.widget.FrameLayout) ZhihuFragment(com.looklook.xinghongfei.looklook.fragment.ZhihuFragment) CompoundButton(android.widget.CompoundButton)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)37 View (android.view.View)37 Intent (android.content.Intent)18 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)18 TextView (android.widget.TextView)16 ImageView (android.widget.ImageView)15 Preference (android.support.v7.preference.Preference)14 Context (android.content.Context)13 PreferenceCategory (android.support.v7.preference.PreferenceCategory)12 BroadcastReceiver (android.content.BroadcastReceiver)8 IntentFilter (android.content.IntentFilter)7 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)7 Button (android.widget.Button)7 DimmableIconPreference (com.android.settings.DimmableIconPreference)7 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)7 FloatingActionButton (android.support.design.widget.FloatingActionButton)6 OnClickListener (android.view.View.OnClickListener)6 FrameLayout (android.widget.FrameLayout)6 SharedPreferences (android.content.SharedPreferences)5 SwitchPreference (android.support.v14.preference.SwitchPreference)5