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;
}
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();
}
});
}
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();
}
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);
}
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());
}
});
}
Aggregations