androidx.appcompat.widget.Toolbar Java Examples

The following examples show how to use androidx.appcompat.widget.Toolbar. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HelpActivity.java    From habpanelviewer with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_help);

    Toolbar myToolbar = findViewById(R.id.toolbar);
    setSupportActionBar(myToolbar);

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

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    String theme = prefs.getString(Constants.PREF_THEME, "dark");

    if ("dark".equals(theme)) {
        myToolbar.setPopupTheme(R.style.Theme_AppCompat_NoActionBar);
    } else {
        myToolbar.setPopupTheme(R.style.Theme_AppCompat_Light_NoActionBar);
    }

    showHelp();
}
 
Example #2
Source File: DataLegendActivity.java    From proofmode with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_data_legend);

    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    TextView title = toolbar.findViewById(R.id.toolbar_title);
    title.setText(getTitle());

    WebView webView = findViewById(R.id.webView);

    WebSettings webSetting = webView.getSettings();
    webSetting.setBuiltInZoomControls(false);
    webSetting.setJavaScriptEnabled(false);

    webView.setWebViewClient(new WebViewClient());
    webView.loadUrl("file:///android_asset/datalegend/datalegend.html");
}
 
Example #3
Source File: LogMessageActivity.java    From loco-answers with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_log_message);
    appInfo = (TextView) findViewById(R.id.appInfo);

    Intent intent = getIntent();
    if (intent != null) {
        String dirPath = intent.getStringExtra("LogMessage");
        File file = new File(dirPath);
        crashLog = FileUtils.readFromFile(file);
        TextView textView = (TextView) findViewById(R.id.logMessage);
        textView.setText(crashLog);
    }

    Toolbar myToolbar = (Toolbar) findViewById(R.id.toolbar);
    myToolbar.setTitle(getString(R.string.crash_reporter));
    setSupportActionBar(myToolbar);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    getAppInfo();
}
 
Example #4
Source File: FormFragment.java    From shaky-android with Apache License 2.0 6 votes vote down vote up
@NonNull
private Toolbar.OnMenuItemClickListener createMenuClickListener(@NonNull final EditText messageEditText) {
    return new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (item.getItemId() == R.id.action_submit) {
                String message = messageEditText.getText().toString();

                if (validate(message)) {
                    Intent intent = new Intent(ACTION_SUBMIT_FEEDBACK);
                    intent.putExtra(EXTRA_USER_MESSAGE, message);
                    LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(intent);
                    return true;
                }
            }
            return false;
        }
    };
}
 
Example #5
Source File: MainActivity.java    From ChromeLikeTabSwitcher with Apache License 2.0 6 votes vote down vote up
@Override
public void onShowTab(@NonNull final Context context,
                      @NonNull final TabSwitcher tabSwitcher, @NonNull final View view,
                      @NonNull final Tab tab, final int index, final int viewType,
                      @Nullable final State state,
                      @Nullable final Bundle savedInstanceState) {
    TextView textView = findViewById(android.R.id.title);
    textView.setText(tab.getTitle());
    Toolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setVisibility(tabSwitcher.isSwitcherShown() ? View.GONE : View.VISIBLE);

    if (viewType == 1) {
        EditText editText = findViewById(android.R.id.edit);

        if (savedInstanceState == null) {
            editText.setText(null);
        }

        editText.requestFocus();
    } else if (viewType == 2 && state != null) {
        ListView listView = findViewById(android.R.id.list);
        state.loadItems(listView);
    }
}
 
Example #6
Source File: ScrollingActivity.java    From recycler-fast-scroll with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_simple_scrolling);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    RecyclerView view = findViewById(R.id.recyclerview);
    view.setAdapter(new ItemAdapter());
    view.setLayoutManager(new LinearLayoutManager(this));

    mRecyclerFastScroller = findViewById(R.id.fast_scroller);
    mRecyclerFastScroller.attachRecyclerView(view);

    setTitle(R.string.title);
}
 
Example #7
Source File: MainActivity.java    From MaterialTapTargetPrompt with Apache License 2.0 6 votes vote down vote up
public void showStylePrompt(View view)
{
    final MaterialTapTargetPrompt.Builder builder = new MaterialTapTargetPrompt.Builder(this, R.style.MaterialTapTargetPromptTheme_FabTarget);
    final Toolbar tb = this.findViewById(R.id.toolbar);
    final View child = tb.getChildAt(2);
    if (child instanceof ActionMenuView)
    {
        final ActionMenuView actionMenuView = ((ActionMenuView) child);
        builder.setTarget(actionMenuView.getChildAt(actionMenuView.getChildCount() - 1));
    }
    else
    {
        Toast.makeText(this, R.string.overflow_unavailable, Toast.LENGTH_SHORT).show();
    }
    builder.setIcon(R.drawable.ic_more_vert)
            .show();
}
 
Example #8
Source File: CameraPrefsActivity.java    From evercam-android with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_settings);

    Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
    toolbar.setBackgroundColor(getResources().getColor(R.color.dark_gray_background));
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    screenWidth = CamerasActivity.readScreenWidth(this);

    getFragmentManager().beginTransaction().replace(R.id.content_frame,
            new MyPreferenceFragment()).commit();
    this.setDefaultKeyMode(DEFAULT_KEYS_DISABLE);
}
 
Example #9
Source File: GalleryListScene.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateDrawerView(LayoutInflater inflater, @Nullable ViewGroup container,
                               @Nullable Bundle savedInstanceState) {
    Context context = getContext2();
    AssertUtils.assertNotNull(context);

    View view = inflater.inflate(R.layout.drawer_list, container, false);
    Toolbar toolbar = (Toolbar) ViewUtils.$$(view, R.id.toolbar);
    this.timeView = (RadioGridGroup) ViewUtils.$$(view, R.id.draw_top_time);
    this.categoryView = (RadioGridGroup) ViewUtils.$$(view, R.id.draw_top_category);

    updateTopCategory();

    toolbar.setTitle(R.string.category_tip);
    return view;
}
 
Example #10
Source File: ToolbarHelper.java    From Paginize with MIT License 6 votes vote down vote up
public static void setNavigationIconEnabled(Toolbar toolbar,
                                            boolean enable,
                                            View.OnClickListener listener) {
  Drawable navIcon = toolbar.getNavigationIcon();
  if (enable) {
    if (navIcon != null) {
      navIcon.setVisible(true, false);
    } else {
      toolbar.setNavigationIcon(R.drawable.paginize_contrib_ic_arrow_back_white_24dp);
      if (listener != null) {
        toolbar.setNavigationOnClickListener(listener);
      }
    }
  } else if (navIcon != null){
    navIcon.setVisible(false, false);
  }
}
 
Example #11
Source File: NavigationDrawerFragment.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    Toolbar toolbar = view.findViewById(R.id.toolbar);
    setupToolbar(toolbar);

    initDrawerLayout(view, toolbar);
    initNavigationView(view);

    mViewPager = view.findViewById(R.id.pager);
    TabLayout tabLayout = view.findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);
    tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);

    super.onViewCreated(view, savedInstanceState);
    mPresenter.loadBoardInfo();
}
 
Example #12
Source File: PinActivity.java    From green_android with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!AuthenticationHandler.hasPin(this)) {
        startActivity(new Intent(this, FirstScreenActivity.class));
        finish();
        return;
    }

    setContentView(R.layout.activity_pin);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    setTitleBackTransparent();

    if (AuthenticationHandler.getNativeAuth(this) != null)
        onNativeAuth();
    else if (AuthenticationHandler.getPinAuth(this) != null)
        onPinAuth();
}
 
Example #13
Source File: MainActivity.java    From centering-recycler-view with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mRecyclerView = findViewById(R.id.recycler_view);
    mRecyclerView.setAdapter(new DemoAdapter(R.layout.linear_vertical));
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));

    final FloatingActionButton fab = findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            int position = mRand.nextInt(DemoAdapter.ITEM_COUNT);
            mRecyclerView.center(position);
            ActionBar ab = getSupportActionBar();
            if (ab != null) {
                ab.setSubtitle(getString(R.string.subtitle, position));
            }
        }
    });
}
 
Example #14
Source File: SlideItemActivity.java    From RecyclerViewHelper with Apache License 2.0 6 votes vote down vote up
private void init() {
    Toolbar toolbar = findViewById(R.id.toolbar);
    mRecyclerView = findViewById(R.id.recycler_view);

    // Toolbar replace ActionBar
    setSupportActionBar(toolbar);

    // Simulate get data
    getData();
    mSlideItemAdapter = new SlideItemAdapter(mDataList);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(linearLayoutManager);
    SuperDividerItemDecoration dividerItemDecoration = new SuperDividerItemDecoration(this,
            linearLayoutManager);
    dividerItemDecoration.setDividerHeight(DensityUtils.dp2px(this, 10));
    mRecyclerView.addItemDecoration(dividerItemDecoration);
    mRecyclerView.setAdapter(mSlideItemAdapter);
}
 
Example #15
Source File: MenuIntroFragment.java    From prayer-times-android with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.intro_menu, container, false);
    
    
    Toolbar toolbar = v.findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.appName);
    toolbar.setNavigationIcon(
            MaterialDrawableBuilder.with(getActivity()).setIcon(MaterialDrawableBuilder.IconValue.MENU).setColorResource(R.color.white)
                    .setToActionbarSize().build());
    
    mDrawerLayout = v.findViewById(R.id.drawer);
    mDrawerLayout.setBackgroundResource(R.color.background);
    
    ListView lv = v.findViewById(R.id.base_nav);
    lv.setAdapter(buildNavAdapter(getActivity()));
    
    return v;
}
 
Example #16
Source File: MainActivity.java    From AndroidDeviceNames with Apache License 2.0 6 votes vote down vote up
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  Toolbar toolbar = findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);

  setDeviceNameText();

  editTextCodename = findViewById(R.id.input_codename);
  editTextModel = findViewById(R.id.input_model);
  result = findViewById(R.id.result);

  editTextCodename.setText(Build.DEVICE);
  editTextModel.setText(Build.MODEL);

  findViewById(R.id.btn).setOnClickListener(this);
}
 
Example #17
Source File: UCropActivity.java    From EasyPhotos with Apache License 2.0 6 votes vote down vote up
/**
 * Configures and styles both status bar and toolbar.
 */
private void setupAppBar() {
    setStatusBarColor(mStatusBarColor);

    final Toolbar toolbar = findViewById(R.id.toolbar);

    // Set all of the Toolbar coloring
    toolbar.setBackgroundColor(mToolbarColor);
    toolbar.setTitleTextColor(mToolbarWidgetColor);

    final TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
    toolbarTitle.setTextColor(mToolbarWidgetColor);
    toolbarTitle.setText(mToolbarTitle);

    // Color buttons inside the Toolbar
    Drawable stateButtonDrawable = ContextCompat.getDrawable(this, mToolbarCancelDrawable).mutate();
    stateButtonDrawable.setColorFilter(mToolbarWidgetColor, PorterDuff.Mode.SRC_ATOP);
    toolbar.setNavigationIcon(stateButtonDrawable);

    setSupportActionBar(toolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(false);
    }
}
 
Example #18
Source File: ScannerActivity.java    From ShadowsocksRR with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_scanner);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(getTitle());
    toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_material);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            navigateUp();
        }
    });

    scannerView = (ZXingScannerView) findViewById(R.id.scanner);

    if (Build.VERSION.SDK_INT >= 25) {
        ShortcutManager service = getSystemService(ShortcutManager.class);
        if (service != null) {
            service.reportShortcutUsed("scan");
        }
    }
}
 
Example #19
Source File: ViewPagerActivity.java    From PhotoDraweeView with Apache License 2.0 6 votes vote down vote up
@Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_viewpager);

    ((Toolbar) findViewById(R.id.toolbar)).setNavigationOnClickListener(
            new View.OnClickListener() {
                @Override public void onClick(View v) {
                    onBackPressed();
                }
            });

    CircleIndicator indicator = findViewById(R.id.indicator);
    MultiTouchViewPager viewPager = findViewById(R.id.view_pager);
    viewPager.setAdapter(new DraweePagerAdapter());
    indicator.setViewPager(viewPager);
}
 
Example #20
Source File: FavoriteActivity.java    From NClientV2 with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Global.initActivity(this);

    setContentView(R.layout.app_bar_main);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    getSupportActionBar().setTitle(R.string.favorite_manga);
    recycler = findViewById(R.id.recycler);
    refresher = findViewById(R.id.refresher);
    refresher.setRefreshing(true);
    final FavoriteAdapter adapter = new FavoriteAdapter(this);

    findViewById(R.id.page_switcher).setVisibility(View.GONE);

    refresher.setOnRefreshListener(adapter::forceReload);
    changeLayout(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
    recycler.setAdapter(adapter);


}
 
Example #21
Source File: BookmarkActivity.java    From NClientV2 with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Global.initActivity(this);
    setContentView(R.layout.activity_bookmark);
    Toolbar toolbar=findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    getSupportActionBar().setTitle(R.string.manage_bookmarks);

    recycler=findViewById(R.id.recycler);
    adapter=new BookmarkAdapter(this);
    recycler.setLayoutManager(new CustomLinearLayoutManager(this));
    recycler.setAdapter(adapter);
}
 
Example #22
Source File: AnimationService.java    From Twire with GNU General Public License v3.0 6 votes vote down vote up
public static void setActivityToolbarReset(Toolbar aMainToolbar, Toolbar aDecorativeToolbar, Activity aActivity, float fromToolbarPosition, float fromMainToolbarPosition) {
    final int TOOLBAR_TRANSLATION_DURATION = 700;
    float DECORATIVE_TOOLBAR_HEIGHT = -1 * aActivity.getResources().getDimension(R.dimen.additional_toolbar_height);
    if (fromMainToolbarPosition == 0) {
        DECORATIVE_TOOLBAR_HEIGHT += aActivity.getResources().getDimension(R.dimen.main_toolbar_height);
    } else {
        Animation moveMainToolbarAnimation = new TranslateAnimation(0, 0, fromMainToolbarPosition, 0);
        moveMainToolbarAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
        moveMainToolbarAnimation.setDuration(TOOLBAR_TRANSLATION_DURATION);

        aMainToolbar.startAnimation(moveMainToolbarAnimation);
    }
    float fromTranslationY = Math.max(fromToolbarPosition, DECORATIVE_TOOLBAR_HEIGHT);

    Animation moveToolbarAnimation = new TranslateAnimation(0, 0, fromTranslationY, 0);
    moveToolbarAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
    moveToolbarAnimation.setDuration(TOOLBAR_TRANSLATION_DURATION);

    aDecorativeToolbar.startAnimation(moveToolbarAnimation);
}
 
Example #23
Source File: LocalActivity.java    From NClientV2 with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Global.initActivity(this);
    setContentView(R.layout.app_bar_main);
    Toolbar toolbar=findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    getSupportActionBar().setTitle(R.string.downloaded_manga);
    findViewById(R.id.page_switcher).setVisibility(View.GONE);
    recycler=findViewById(R.id.recycler);
    refresher=findViewById(R.id.refresher);
    refresher.setOnRefreshListener(() -> new FakeInspector(folder).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,LocalActivity.this));
    changeLayout(getResources().getConfiguration().orientation==Configuration.ORIENTATION_LANDSCAPE);
    new FakeInspector(folder).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,this);
}
 
Example #24
Source File: MainActivity.java    From Daedalus with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    if (Daedalus.isDarkTheme()) {
        setTheme(R.style.AppTheme_Dark_NoActionBar_TransparentStatusBar);
    }
    super.onCreate(savedInstanceState);

    instance = this;

    setContentView(R.layout.activity_main);
    Toolbar toolbar = findViewById(R.id.toolbar);
    //setSupportActionBar(toolbar); //causes toolbar issues

    DrawerLayout drawer = findViewById(R.id.main_drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    ((TextView) navigationView.getHeaderView(0).findViewById(R.id.textView_nav_version)).setText(getString(R.string.nav_version) + " " + BuildConfig.VERSION_NAME);
    ((TextView) navigationView.getHeaderView(0).findViewById(R.id.textView_nav_git_commit)).setText(getString(R.string.nav_git_commit) + " " + BuildConfig.GIT_COMMIT);

    updateUserInterface(getIntent());
}
 
Example #25
Source File: UploadWidgetFragment.java    From cloudinary_android with MIT License 5 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    AppCompatActivity activity = (AppCompatActivity) getActivity();
    if (activity != null) {
        Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
        activity.setSupportActionBar(toolbar);
        ActionBar actionBar = activity.getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setDisplayShowTitleEnabled(false);
        }
    }
}
 
Example #26
Source File: DefaultDrawerActivity.java    From Drawer-Behavior with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_default);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

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

    drawer = (AdvanceDrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);


}
 
Example #27
Source File: ChannelDiscoveryActivity.java    From Pix-Art-Messenger with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_channel_discovery);
    setSupportActionBar((Toolbar) binding.toolbar);
    configureActionBar(getSupportActionBar(), true);
    binding.list.setAdapter(this.adapter);
    this.adapter.setOnChannelSearchResultSelectedListener(this);
    this.optedIn = getPreferences().getBoolean(CHANNEL_DISCOVERY_OPT_IN, false);

    final String search = savedInstanceState == null ? null : savedInstanceState.getString("search");
    if (search != null) {
        mInitialSearchValue.push(search);
    }
}
 
Example #28
Source File: MainActivity.java    From ElasticDragDismissLayout with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    toolbar.setTitle("ElasticDragDismissLayout");
    toolbar.inflateMenu(R.menu.main);
    toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                case R.id.action_recyclerview:
                    Intent intent = DetailRecyclerViewActivity.newIntent(MainActivity.this);
                    startActivity(intent);
                    return true;
            }
            return false;
        }
    });
    cheeseAdapter = new CheeseAdapter(MainActivity.this, new CheeseAdapter.Listener() {
        @Override
        public void onItemClicked(Cheese cheese) {
            startActivity(DetailActivity.newIntent(MainActivity.this, cheese));
        }
    });
    recyclerView.setAdapter(cheeseAdapter);
    recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
    load();
}
 
Example #29
Source File: TaskerActivity.java    From ShadowsocksRR with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_tasker);

    profilesAdapter = new ProfilesAdapter();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.app_name);
    toolbar.setNavigationIcon(R.drawable.ic_navigation_close);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    taskerOption = TaskerSettings.fromIntent(getIntent());
    mSwitch = (Switch) findViewById(R.id.serviceSwitch);
    mSwitch.setChecked(taskerOption.switchOn);
    RecyclerView profilesList = (RecyclerView) findViewById(R.id.profilesList);
    LinearLayoutManager lm = new LinearLayoutManager(this);
    profilesList.setLayoutManager(lm);
    profilesList.setItemAnimator(new DefaultItemAnimator());
    profilesList.setAdapter(profilesAdapter);

    if (taskerOption.profileId >= 0) {
        int position = 0;
        List<Profile> profiles = profilesAdapter.profiles;
        for (int i = 0; i < profiles.size(); i++) {
            Profile profile = profiles.get(i);
            if (profile.id == taskerOption.profileId) {
                position = i + 1;
                break;
            }
        }
        lm.scrollToPosition(position);
    }
}
 
Example #30
Source File: TopAppBarScrollingDemoFragment.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateDemoView(
    LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
  View view = layoutInflater.inflate(R.layout.cat_topappbar_scrolling_fragment, viewGroup, false);

  Toolbar toolbar = view.findViewById(R.id.toolbar);
  AppCompatActivity activity = (AppCompatActivity) getActivity();
  activity.setSupportActionBar(toolbar);

  return view;
}