use of com.a5corp.weather.fragment.GraphsFragment in project Weather by Sparker0i.
the class WeatherActivity method newGraphInstance.
public static GraphsFragment newGraphInstance(ArrayList<WeatherFort.WeatherList> describable) {
GraphsFragment fragment = new GraphsFragment();
Bundle bundle = new Bundle();
bundle.putSerializable(DESCRIBABLE_KEY, describable);
fragment.setArguments(bundle);
return fragment;
}
use of com.a5corp.weather.fragment.GraphsFragment in project Weather by Sparker0i.
the class WeatherActivity method initDrawer.
public void initDrawer() {
final IProfile profile = new ProfileDrawerItem().withName(getString(R.string.app_name)).withEmail("Version : " + BuildConfig.VERSION_NAME).withIcon(R.mipmap.ic_launcher_x);
AccountHeader headerResult = new AccountHeaderBuilder().withActivity(this).withHeaderBackground(R.drawable.header).withTextColor(ContextCompat.getColor(this, R.color.md_amber_400)).addProfiles(profile).withSelectionListEnabled(false).withProfileImagesClickable(false).build();
SecondaryDrawerItem item1 = new SecondaryDrawerItem().withName(R.string.drawer_item_home).withIcon(new IconicsDrawable(this).icon(WeatherIcons.Icon.wic_day_sunny)).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
wf = new WeatherFragment();
getSupportFragmentManager().beginTransaction().replace(R.id.fragment, wf).commit();
return true;
}
});
SecondaryDrawerItem item2 = new SecondaryDrawerItem().withName(R.string.drawer_item_graph).withIcon(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_trending_up)).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
if (!(f instanceof GraphsFragment)) {
GraphsFragment graphsFragment = newGraphInstance(new ArrayList<>(wf.getDailyJson()));
getSupportFragmentManager().beginTransaction().replace(R.id.fragment, graphsFragment).commit();
}
return true;
}
});
SecondaryDrawerItem item3 = new SecondaryDrawerItem().withName(R.string.drawer_item_map).withIcon(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_map)).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
if (!(f instanceof MapsFragment)) {
MapsFragment mapsFragment = new MapsFragment();
getSupportFragmentManager().beginTransaction().replace(R.id.fragment, mapsFragment).commit();
}
return true;
}
});
SecondaryDrawerItem item4 = new SecondaryDrawerItem().withName(R.string.drawer_item_add_city).withIcon(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_add_location)).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
showCityDialog();
return true;
}
}).withSelectable(false);
SecondaryDrawerItem item8 = new SecondaryDrawerItem().withName(R.string.drawer_item_about).withIcon(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_info)).withSelectable(false).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
startActivity(new Intent(WeatherActivity.this, AboutActivity.class));
return true;
}
});
SecondaryDrawerItem item9 = new SecondaryDrawerItem().withName(R.string.settings).withIcon(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_settings)).withSelectable(false).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
startActivity(new Intent(WeatherActivity.this, SettingsActivity.class));
return true;
}
});
DrawerBuilder drawerBuilder = new DrawerBuilder();
drawerBuilder.withActivity(this).withToolbar(toolbar).withTranslucentStatusBar(true).withAccountHeader(headerResult).withActionBarDrawerToggleAnimated(true).addDrawerItems(item1, item2, item3, new DividerDrawerItem(), item4).addStickyDrawerItems(item8, item9);
List<String> cities = dbHelper.getCities();
final ListIterator<String> listIterator = cities.listIterator(cities.size());
while (listIterator.hasPrevious()) {
final String city = listIterator.previous();
drawerBuilder.addDrawerItems(new SecondaryDrawerItem().withName(city).withIcon(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_place)).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
wf = new WeatherFragment().setCity(city);
getSupportFragmentManager().beginTransaction().replace(R.id.fragment, wf).commit();
return true;
}
}));
}
drawer = drawerBuilder.build();
}
use of com.a5corp.weather.fragment.GraphsFragment in project Weather by Sparker0i.
the class WeatherActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_weather);
Log.i("Activity", WeatherActivity.class.getSimpleName());
mManager = NotificationManagerCompat.from(this);
preferences = new Prefs(this);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
hideFab();
showInputDialog();
}
});
Intent intent = getIntent();
handler = new Handler();
fab.show();
wf = new WeatherFragment();
Bundle bundle = new Bundle();
bundle.putInt("mode", intent.getIntExtra(Constants.MODE, 0));
wf.setArguments(bundle);
gf = new GraphsFragment();
// mf = new MapsFragment();
dbHelper = new DBHelper(this);
getSupportFragmentManager().beginTransaction().replace(R.id.fragment, wf).commit();
initDrawer();
NotificationService.enqueueWork(this, new Intent(this, WeatherActivity.class));
}
Aggregations