mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-09-05 14:06:31 +02:00
84 lines
2.6 KiB
Java
84 lines
2.6 KiB
Java
|
package nodomain.freeyourgadget.gadgetbridge.activities.appmanager;
|
||
|
|
||
|
import android.os.Bundle;
|
||
|
import android.support.v4.app.Fragment;
|
||
|
import android.support.v4.app.FragmentManager;
|
||
|
import android.support.v4.view.ViewPager;
|
||
|
|
||
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||
|
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractFragmentPagerAdapter;
|
||
|
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractGBFragmentActivity;
|
||
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||
|
|
||
|
|
||
|
public class AppManagerActivity extends AbstractGBFragmentActivity {
|
||
|
private GBDevice mGBDevice = null;
|
||
|
|
||
|
@Override
|
||
|
protected void onCreate(Bundle savedInstanceState) {
|
||
|
|
||
|
super.onCreate(savedInstanceState);
|
||
|
|
||
|
setContentView(R.layout.activity_fragmentappmanager);
|
||
|
|
||
|
Bundle extras = getIntent().getExtras();
|
||
|
if (extras != null) {
|
||
|
mGBDevice = extras.getParcelable(GBDevice.EXTRA_DEVICE);
|
||
|
} else {
|
||
|
throw new IllegalArgumentException("Must provide a device when invoking this activity");
|
||
|
}
|
||
|
|
||
|
|
||
|
// Set up the ViewPager with the sections adapter.
|
||
|
ViewPager viewPager = (ViewPager) findViewById(R.id.appmanager_pager);
|
||
|
viewPager.setAdapter(getPagerAdapter());
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected AbstractFragmentPagerAdapter createFragmentPagerAdapter(FragmentManager fragmentManager) {
|
||
|
return new SectionsPagerAdapter(fragmentManager);
|
||
|
}
|
||
|
|
||
|
public class SectionsPagerAdapter extends AbstractFragmentPagerAdapter {
|
||
|
|
||
|
public SectionsPagerAdapter(FragmentManager fm) {
|
||
|
super(fm);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public Fragment getItem(int position) {
|
||
|
// getItem is called to instantiate the fragment for the given page.
|
||
|
switch (position) {
|
||
|
case 0:
|
||
|
case 1:
|
||
|
case 2:
|
||
|
AbstractAppManagerFragment fragment = new AbstractAppManagerFragment();
|
||
|
Bundle bundle = new Bundle();
|
||
|
bundle.putParcelable("GBDevice", mGBDevice);
|
||
|
return fragment;
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public int getCount() {
|
||
|
return 3;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public CharSequence getPageTitle(int position) {
|
||
|
switch (position) {
|
||
|
case 0:
|
||
|
return "test";
|
||
|
case 1:
|
||
|
return "for";
|
||
|
case 2:
|
||
|
return "me";
|
||
|
case 3:
|
||
|
}
|
||
|
return super.getPageTitle(position);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|