Search in sources :

Example 61 with UP

use of android.support.v7.widget.helper.ItemTouchHelper.UP in project AndroidStudy by tinggengyan.

the class PullToZoomRecyclerViewEx method isFirstItemVisible.

private boolean isFirstItemVisible() {
    if (mRootView != null) {
        final RecyclerView.Adapter adapter = mRootView.getAdapter();
        final GridLayoutManager mLayoutmanager = (GridLayoutManager) mRootView.getLayoutManager();
        if (null == adapter || adapter.getItemCount() == 0) {
            return true;
        } else {
            /**
             * This check should really just be:
             * mRootView.getFirstVisiblePosition() == 0, but PtRListView
             * internally use a HeaderView which messes the positions up. For
             * now we'll just add one to account for it and rely on the inner
             * condition which checks getTop().
             */
            int[] into = { 0, 0 };
            if (mLayoutmanager != null)
                into[0] = mLayoutmanager.findFirstVisibleItemPosition();
            if (into.length > 0 && into.length > 0 && into[0] <= 1) {
                final View firstVisibleChild = mRootView.getChildAt(0);
                if (firstVisibleChild != null) {
                    return firstVisibleChild.getTop() >= mRootView.getTop();
                }
            }
        }
    }
    return false;
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) ImageView(android.widget.ImageView) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 62 with UP

use of android.support.v7.widget.helper.ItemTouchHelper.UP in project Pitampura_Android_2018_Spring by coding-blocks-archives.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null).show();
        }
    });
}
Also used : FloatingActionButton(android.support.design.widget.FloatingActionButton) TextView(android.widget.TextView) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Example 63 with UP

use of android.support.v7.widget.helper.ItemTouchHelper.UP in project AboutLibraries by mikepenz.

the class FragmentActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fragment);
    // Remove line to test RTL support
    // getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    new DrawerBuilder(this).withToolbar(toolbar).addDrawerItems(new PrimaryDrawerItem().withName("Home"), new PrimaryDrawerItem().withName(R.string.action_manifestactivity).withIdentifier(R.id.action_manifestactivity).withSelectable(false), new PrimaryDrawerItem().withName(R.string.action_extendactivity).withIdentifier(R.id.action_extendactivity).withSelectable(false), new PrimaryDrawerItem().withName(R.string.action_customsortactivity).withIdentifier(R.id.action_customsortactivity).withSelectable(false), new PrimaryDrawerItem().withName(R.string.action_opensource).withIdentifier(R.id.action_opensource).withSelectable(false)).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {

        @Override
        public boolean onItemClick(View view, int i, IDrawerItem drawerItem) {
            // Handle action bar item clicks here. The action bar will
            // automatically handle clicks on the Home/Up button, so long
            // as you specify a parent activity in AndroidManifest.xml.
            long id = drawerItem.getIdentifier();
            if (id == R.id.action_opensource) {
                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/mikepenz/AboutLibraries"));
                startActivity(browserIntent);
            } else if (id == R.id.action_extendactivity) {
                Intent intent = new Intent(getApplicationContext(), ExtendActivity.class);
                startActivity(intent);
            } else if (id == R.id.action_customsortactivity) {
                Intent intent = new Intent(getApplicationContext(), CustomSortActivity.class);
                startActivity(intent);
            } else if (id == R.id.action_manifestactivity) {
                new LibsBuilder().withLibraries("crouton", "actionbarsherlock", "showcaseview", "android_job").withAutoDetect(false).withLicenseShown(true).withVersionShown(true).withActivityTitle("Open Source").withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR).withListener(libsListener).withLibTaskCallback(libTaskCallback).withUiListener(libsUIListener).start(FragmentActivity.this);
            }
            return false;
        }
    }).build();
    /*
        //NOTE: This is how you can modify a specific library definition during runtime
        HashMap<String, HashMap<String, String>> libsModification = new HashMap<String, HashMap<String, String>>();
        HashMap<String, String> modifyAboutLibraries = new HashMap<String, String>();
        modifyAboutLibraries.put("name", "_AboutLibraries");
        libsModification.put("aboutlibraries", modifyAboutLibraries);
        .withLibraryModification(libsModification);
        */
    LibsSupportFragment fragment = new LibsBuilder().withVersionShown(false).withLicenseShown(true).withLibraryModification("aboutlibraries", Libs.LibraryFields.LIBRARY_NAME, "_AboutLibraries").supportFragment();
    FragmentManager fragmentManager = getSupportFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).commit();
}
Also used : LibsSupportFragment(com.mikepenz.aboutlibraries.ui.LibsSupportFragment) FragmentManager(android.support.v4.app.FragmentManager) PrimaryDrawerItem(com.mikepenz.materialdrawer.model.PrimaryDrawerItem) IDrawerItem(com.mikepenz.materialdrawer.model.interfaces.IDrawerItem) LibsBuilder(com.mikepenz.aboutlibraries.LibsBuilder) Intent(android.content.Intent) DrawerBuilder(com.mikepenz.materialdrawer.DrawerBuilder) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Example 64 with UP

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

the class AboutActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ThemeHelper.setTheme(this);
    setContentView(R.layout.activity_about);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    // Set up the ViewPager with the sections adapter.
    mViewPager = findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    TabLayout tabLayout = findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);
}
Also used : TabLayout(android.support.design.widget.TabLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 65 with UP

use of android.support.v7.widget.helper.ItemTouchHelper.UP in project Carebase by robertsimoes.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    /**
     * Set Toolbar
     */
    Toolbar myToolbar = (Toolbar) findViewById(R.id.general_fragments_toolbar);
    setSupportActionBar(myToolbar);
    ILocalCache cache = new LocalCacheDb(this);
    String userId = cache.getUserId();
    boolean isFirstInstall = cache.isFirstInstall();
    if (isFirstInstall) {
        cache.setFirstInstall(false);
        startActivity(new Intent(this, IntroActivity.class));
    }
    /* Get Patient Info */
    src.getPatient(userId, new ValueEventListener() {

        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            Toast.makeText(MainActivity.this, "Welcome Back!", Toast.LENGTH_SHORT).show();
            Log.d("TAG", "SUCCESS \n\n\n\n ------");
            Patient p = dataSnapshot.getValue(Patient.class);
            fragmentArgs = new Bundle();
            fragmentArgs.putSerializable(Const.BUNDLE_KEY_PATIENT, p);
            BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.main_bottom_navigation);
            bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {

                @Override
                public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                    switch(item.getItemId()) {
                        case R.id.action_inbox:
                            invalidateOptionsMenu();
                            selectedFragment = InboxFragment.newInstance(fragmentArgs);
                            currentFragment = Frag.INBOX;
                            break;
                        case R.id.action_appointments:
                            invalidateOptionsMenu();
                            AppointmentsFragment f = AppointmentsFragment.newInstance(fragmentArgs);
                            f.setCallback(MainActivity.this);
                            selectedFragment = f;
                            currentFragment = Frag.APPOINTMENTS;
                            break;
                        case R.id.action_rx:
                            invalidateOptionsMenu();
                            selectedFragment = RxFragment.newInstance(fragmentArgs);
                            currentFragment = Frag.RX;
                            break;
                        case R.id.action_profile:
                            invalidateOptionsMenu();
                            selectedFragment = ProfileFragment.newInstance(fragmentArgs);
                            currentFragment = Frag.PROFILE_EDIT;
                            break;
                    }
                    refreshFragmentUI(selectedFragment);
                    return true;
                }
            });
        // Before the application or user has picked anything to display
        // Let's just display the inbox fragment by default so that when the app loads up
        // we pick that.
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
            Log.e("ERR", "Could not load patient snapshot" + databaseError.getDetails());
        }
    });
}
Also used : IntroActivity(com.hci.carebase.ui.activities.IntroActivity) Bundle(android.os.Bundle) Patient(com.hci.carebase.domain.Patient) ILocalCache(com.hci.carebase.data.interfaces.ILocalCache) Intent(android.content.Intent) MenuItem(android.view.MenuItem) DataSnapshot(com.google.firebase.database.DataSnapshot) LocalCacheDb(com.hci.carebase.data.datasource.LocalCacheDb) DatabaseError(com.google.firebase.database.DatabaseError) BottomNavigationView(android.support.design.widget.BottomNavigationView) NonNull(android.support.annotation.NonNull) AppointmentsFragment(com.hci.carebase.ui.fragments.AppointmentsFragment) ValueEventListener(com.google.firebase.database.ValueEventListener) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

View (android.view.View)135 RecyclerView (android.support.v7.widget.RecyclerView)97 TextView (android.widget.TextView)69 Toolbar (android.support.v7.widget.Toolbar)51 ActionBar (android.support.v7.app.ActionBar)49 Intent (android.content.Intent)44 ImageView (android.widget.ImageView)41 AdapterView (android.widget.AdapterView)33 ArrayList (java.util.ArrayList)30 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)29 DialogInterface (android.content.DialogInterface)25 AlertDialog (android.support.v7.app.AlertDialog)25 ListView (android.widget.ListView)25 Bundle (android.os.Bundle)22 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)22 SharedPreferences (android.content.SharedPreferences)21 Preference (android.support.v7.preference.Preference)20 GridLayoutManager (android.support.v7.widget.GridLayoutManager)19 SuppressLint (android.annotation.SuppressLint)16 Point (android.graphics.Point)16