Search in sources :

Example 1 with GraphsFragment

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;
}
Also used : Bundle(android.os.Bundle) GraphsFragment(com.a5corp.weather.fragment.GraphsFragment)

Example 2 with GraphsFragment

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();
}
Also used : IDrawerItem(com.mikepenz.materialdrawer.model.interfaces.IDrawerItem) DividerDrawerItem(com.mikepenz.materialdrawer.model.DividerDrawerItem) ProfileDrawerItem(com.mikepenz.materialdrawer.model.ProfileDrawerItem) ArrayList(java.util.ArrayList) AccountHeaderBuilder(com.mikepenz.materialdrawer.AccountHeaderBuilder) Intent(android.content.Intent) WeatherFragment(com.a5corp.weather.fragment.WeatherFragment) Drawer(com.mikepenz.materialdrawer.Drawer) SecondaryDrawerItem(com.mikepenz.materialdrawer.model.SecondaryDrawerItem) View(android.view.View) AccountHeader(com.mikepenz.materialdrawer.AccountHeader) MapsFragment(com.a5corp.weather.fragment.MapsFragment) IProfile(com.mikepenz.materialdrawer.model.interfaces.IProfile) DrawerBuilder(com.mikepenz.materialdrawer.DrawerBuilder) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) GraphsFragment(com.a5corp.weather.fragment.GraphsFragment)

Example 3 with GraphsFragment

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));
}
Also used : Bundle(android.os.Bundle) DBHelper(com.a5corp.weather.preferences.DBHelper) Handler(android.os.Handler) Intent(android.content.Intent) WeatherFragment(com.a5corp.weather.fragment.WeatherFragment) Prefs(com.a5corp.weather.preferences.Prefs) View(android.view.View) GraphsFragment(com.a5corp.weather.fragment.GraphsFragment)

Aggregations

GraphsFragment (com.a5corp.weather.fragment.GraphsFragment)3 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 View (android.view.View)2 WeatherFragment (com.a5corp.weather.fragment.WeatherFragment)2 Handler (android.os.Handler)1 MapsFragment (com.a5corp.weather.fragment.MapsFragment)1 DBHelper (com.a5corp.weather.preferences.DBHelper)1 Prefs (com.a5corp.weather.preferences.Prefs)1 IconicsDrawable (com.mikepenz.iconics.IconicsDrawable)1 AccountHeader (com.mikepenz.materialdrawer.AccountHeader)1 AccountHeaderBuilder (com.mikepenz.materialdrawer.AccountHeaderBuilder)1 Drawer (com.mikepenz.materialdrawer.Drawer)1 DrawerBuilder (com.mikepenz.materialdrawer.DrawerBuilder)1 DividerDrawerItem (com.mikepenz.materialdrawer.model.DividerDrawerItem)1 ProfileDrawerItem (com.mikepenz.materialdrawer.model.ProfileDrawerItem)1 SecondaryDrawerItem (com.mikepenz.materialdrawer.model.SecondaryDrawerItem)1 IDrawerItem (com.mikepenz.materialdrawer.model.interfaces.IDrawerItem)1 IProfile (com.mikepenz.materialdrawer.model.interfaces.IProfile)1 ArrayList (java.util.ArrayList)1