@Override
  public void setContentView(int layoutResID) {
    super.setContentView(R.layout.activity_punjit_base);

    // Add inflated UI to container
    mContentLayout = (LinearLayout) findViewById(R.id.content_layout);

    // Inflate actual UI provided by child activity
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View oView = inflater.inflate(layoutResID, null);

    /*
     *  Even if you give match parent height in xml, still view becomes height becomes.
     *  So adding this line
     */
    oView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    mContentLayout.addView(oView);

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
      mTitle = mDrawerTitle = getTitle();
      mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
      mSliderList = (ListView) findViewById(R.id.slider_list);

      // set a custom shadow that overlays the main content when the drawer opens
      // mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

      // set up the drawer's list view with items and click listener
      mSliderList.setAdapter(SliderMenuListAdapter.getInstance(this));
      mSliderList.setOnItemClickListener(new DrawerItemClickListener());

      // enable ActionBar app icon to behave as action to toggle nav drawer
      getSupportActionBar().setDisplayHomeAsUpEnabled(true);
      getSupportActionBar().setHomeButtonEnabled(true);

      // ActionBarDrawerToggle ties together the the proper interactions
      // between the sliding drawer and the action bar app icon
      mDrawerToggle =
          new ActionBarDrawerToggle(
              this, // host Activity
              mDrawerLayout,
              R.string.drawer_open, // "open drawer" description for accessibility
              R.string.drawer_close // "close drawer" description for accessibility // DrawerLayout
              // object
              ) {
            public void onDrawerClosed(View view) {
              getSupportActionBar().setTitle(mTitle);
              invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            }

            public void onDrawerOpened(View drawerView) {
              getSupportActionBar().setTitle(mDrawerTitle);
              invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            }
          };
      mDrawerLayout.setDrawerListener(mDrawerToggle);
      mDrawerToggle.syncState();
    }
  }
  @Override
  public void setContentView(@LayoutRes int layout) {
    try {
      super.setContentView(layout);

      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      if (toolbar != null) {
        toolbar.setTitle(R.string.app_name);
        setSupportActionBar(toolbar);

        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        mDrawerToggle =
            new ActionBarDrawerToggle(
                this,
                mDrawerLayout,
                toolbar,
                R.string.open_chapter_title,
                R.string.open_chapter_title) {

              /** Called when a drawer has settled in a completely closed state. */
              public void onDrawerClosed(View view) {
                super.onDrawerClosed(view);
                // getActionBar().setTitle(mTitle);
                // invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()

                ActionBar bar = getSupportActionBar();
                if (bar != null) {
                  bar.setDisplayHomeAsUpEnabled(true);
                  bar.setDisplayShowHomeEnabled(true);
                }
              }

              /** Called when a drawer has settled in a completely open state. */
              public void onDrawerOpened(View drawerView) {
                super.onDrawerOpened(drawerView);
                // getActionBar().setTitle(mDrawerTitle);
                // invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
              }
            };
        ActionBar bar = getSupportActionBar();
        if (bar != null) {
          bar.setDisplayHomeAsUpEnabled(true);
          bar.setDisplayShowHomeEnabled(true);
        }
      } else {
        Log.w(TAG, "No toolbar detected!");
      }
    } catch (InflateException ex) {
      Toast.makeText(
              this,
              "Unable to load application, looks like your device is not supported: "
                  + ex.getMessage(),
              Toast.LENGTH_LONG)
          .show();
      Log.e(TAG, ex.getMessage(), ex);
    }
  }
示例#3
0
 @Override
 public void setContentView(int layoutResID) {
   super.setContentView(layoutResID);
   SystemBarTintManager tintManager = new SystemBarTintManager(this);
   tintManager.setStatusBarTintEnabled(true);
   tintManager.setTintColor(getResources().getColor(R.color.system_press));
   initView();
   initData();
 }
 @Override
 public void setContentView(int layoutResID) {
   super.setContentView(layoutResID);
   ButterKnife.inject(this);
   mToolbar = ButterKnife.findById(this, R.id.common_toolbar);
   if (mToolbar != null) {
     setSupportActionBar(mToolbar);
     getSupportActionBar().setHomeButtonEnabled(true);
     getSupportActionBar().setDisplayHomeAsUpEnabled(true);
   }
 }
示例#5
0
  @Override
  public void setContentView(int layoutResID) {
    super.setContentView(layoutResID);

    // butterknife
    bindViews();

    validate();

    afterViews();
  }
  @Override
  public void setContentView(int layoutResID) {

    DrawerLayout fullLayout =
        (DrawerLayout) getLayoutInflater().inflate(R.layout.activity_base, null);
    FrameLayout frameLayout = (FrameLayout) fullLayout.findViewById(R.id.frame_layout_base);

    getLayoutInflater().inflate(layoutResID, frameLayout, true);

    super.setContentView(fullLayout);
    setView();
  }
  @Override
  public void setContentView(int layoutResID) {
    super.setContentView(layoutResID);

    bindViews();

    initVariables();

    validate();

    afterViews();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.setContentView(R.layout.md_drawer_activity);

    mDrawer = (DrawerFrameLayout) findViewById(R.id.mdDrawerLayout);
    mDefaultToolbar = (Toolbar) findViewById(R.id.mdToolbar);
    mFrame = (FrameLayout) findViewById(R.id.mdFrame);

    setSupportActionBar(mDefaultToolbar);

    mDrawer.closeDrawer();
  }
  @Override
  public void setContentView(@LayoutRes int layoutResId) {
    super.setContentView(layoutResId);

    try {
      View statusHeaderView = findViewById(R.id.statusHeaderView);
      statusHeaderView.getLayoutParams().height = statusBarHeight;
    } catch (NullPointerException e) {

    }

    try {
      mToolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(mToolbar);
    } catch (Exception e) {

    }
    mActionBar = getSupportActionBar();

    setUpViews();
  }
示例#10
0
 @Override
 public void setContentView(int layoutResID) {
   super.setContentView(layoutResID);
   getActionBarToolbar();
 }
示例#11
0
 @Override
 public void setContentView(@LayoutRes int layoutResID) {
   super.setContentView(layoutResID);
   ButterKnife.bind(this);
 }
 @Override
 public void setContentView(int layoutResID) {
   super.setContentView(layoutResID);
   toolbar = (Toolbar) findViewById(R.id.toolbar);
   setSupportActionBar(toolbar);
 }
示例#13
0
  @Override
  public void setContentView(int viewId) {
    if (isTv()) {
      super.setContentView(R.layout.static_drawer_activity);
    } else {
      super.setContentView(R.layout.abstract_activity);
    }
    rootView = (ViewGroup) findViewById(R.id.content_frame);

    if (viewId != 0) {
      LayoutInflater layoutInflater = getLayoutInflater();
      layoutInflater.inflate(viewId, rootView);
    }

    drawerList = (NavigationView) findViewById(R.id.left_drawer);
    drawerList.setNavigationItemSelectedListener(
        new NavigationView.OnNavigationItemSelectedListener() {
          @Override
          public boolean onNavigationItemSelected(final MenuItem menuItem) {
            if (showingTabs) {
              // Settings are on a different selectable track
              if (menuItem.getItemId() != R.id.drawer_settings
                  && menuItem.getItemId() != R.id.drawer_admin
                  && menuItem.getItemId() != R.id.drawer_offline) {
                menuItem.setChecked(true);
                lastSelectedPosition = menuItem.getItemId();
              }

              switch (menuItem.getItemId()) {
                case R.id.drawer_home:
                  drawerItemSelected("Home");
                  return true;
                case R.id.drawer_library:
                  drawerItemSelected("Artist");
                  return true;
                case R.id.drawer_playlists:
                  drawerItemSelected("Playlist");
                  return true;
                case R.id.drawer_podcasts:
                  drawerItemSelected("Podcast");
                  return true;
                case R.id.drawer_bookmarks:
                  drawerItemSelected("Bookmark");
                  return true;
                case R.id.drawer_shares:
                  drawerItemSelected("Share");
                  return true;
                case R.id.drawer_chat:
                  drawerItemSelected("Chat");
                  return true;
                case R.id.drawer_admin:
                  if (UserUtil.isCurrentAdmin()) {
                    UserUtil.confirmCredentials(
                        SubsonicActivity.this,
                        new Runnable() {
                          @Override
                          public void run() {
                            drawerItemSelected("Admin");
                            menuItem.setChecked(true);
                            lastSelectedPosition = menuItem.getItemId();
                          }
                        });
                  } else {
                    drawerItemSelected("Admin");
                    menuItem.setChecked(true);
                    lastSelectedPosition = menuItem.getItemId();
                  }
                  return true;
                case R.id.drawer_downloading:
                  drawerItemSelected("Download");
                  return true;
                case R.id.drawer_offline:
                  toggleOffline();
                  return true;
                case R.id.drawer_settings:
                  startActivity(new Intent(SubsonicActivity.this, SettingsActivity.class));
                  drawer.closeDrawers();
                  return true;
              }
            } else {
              int activeServer = menuItem.getItemId() - MENU_ITEM_SERVER_BASE;
              SubsonicActivity.this.setActiveServer(activeServer);
              populateTabs();
              return true;
            }

            return false;
          }
        });

    drawerHeader = drawerList.inflateHeaderView(R.layout.drawer_header);
    drawerHeader.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (showingTabs) {
              populateServers();
            } else {
              populateTabs();
            }
          }
        });

    drawerHeaderToggle = (ImageView) drawerHeader.findViewById(R.id.header_select_image);
    drawerServerName = (TextView) drawerHeader.findViewById(R.id.header_server_name);
    drawerUserName = (TextView) drawerHeader.findViewById(R.id.header_user_name);

    drawerUserAvatar = (ImageView) drawerHeader.findViewById(R.id.header_user_avatar);

    updateDrawerHeader();

    if (!isTv()) {
      drawer = (DrawerLayout) findViewById(R.id.drawer_layout);

      // Pass in toolbar if it exists
      Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar);
      drawerToggle =
          new ActionBarDrawerToggle(
              this, drawer, toolbar, R.string.common_appname, R.string.common_appname) {
            @Override
            public void onDrawerClosed(View view) {
              drawerIdle = true;
              drawerOpen = false;

              if (!showingTabs) {
                populateTabs();
              }
            }

            @Override
            public void onDrawerOpened(View view) {
              DownloadService downloadService = getDownloadService();
              boolean downloadingVisible =
                  downloadService != null && !downloadService.getBackgroundDownloads().isEmpty();
              if (lastSelectedPosition == R.id.drawer_downloading) {
                downloadingVisible = true;
              }
              setDrawerItemVisible(R.id.drawer_downloading, downloadingVisible);

              drawerIdle = true;
              drawerOpen = true;
            }

            @Override
            public void onDrawerSlide(View drawerView, float slideOffset) {
              super.onDrawerSlide(drawerView, slideOffset);
              drawerIdle = false;
            }
          };
      drawer.setDrawerListener(drawerToggle);
      drawerToggle.setDrawerIndicatorEnabled(true);

      drawer.setOnTouchListener(
          new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
              if (drawerIdle
                  && currentFragment != null
                  && currentFragment.getGestureDetector() != null) {
                return currentFragment.getGestureDetector().onTouchEvent(event);
              } else {
                return false;
              }
            }
          });
    }

    // Check whether this is a tablet or not
    secondaryContainer = findViewById(R.id.fragment_second_container);
    if (secondaryContainer != null) {
      primaryContainer = findViewById(R.id.fragment_container);
    }
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   super.setContentView(R.layout.activity_base);
   setView();
 }
示例#15
0
 @Override
 public void setContentView(int layoutResID) {
   super.setContentView(layoutResID);
   ViewUtils.inject(this);
 }