Search in sources :

Example 96 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project TrebleShot by genonbeta.

the class TransactionActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_transaction);
    mDatabase = new AccessDatabase(this);
    mTransactionFragment = (TransactionListFragment) getSupportFragmentManager().findFragmentById(R.id.activity_transaction_listfragment_transaction);
    mPathView = findViewById(R.id.activity_transaction_explorer_recycler);
    mHomeButton = findViewById(R.id.activity_transaction_explorer_image_home);
    mPowafulActionMode = findViewById(R.id.activity_transaction_action_mode);
    // mPowafulActionMode.setContainerLayout(findViewById(R.id.activity_transaction_action_mode_container));
    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mDrawerLayout = findViewById(R.id.drawer_layout);
    if (mDrawerLayout != null) {
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.text_navigationDrawerOpen, R.string.text_navigationDrawerClose);
        mDrawerLayout.addDrawerListener(toggle);
        toggle.syncState();
    }
    mNavigationView = findViewById(R.id.nav_view);
    mNavigationView.setNavigationItemSelectedListener(this);
    mPathView.setHasFixedSize(true);
    mFilter.addAction(AccessDatabase.ACTION_DATABASE_CHANGE);
    mLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
    mPathAdapter = new TransactionPathResolverRecyclerAdapter();
    mPathView.setLayoutManager(mLayoutManager);
    mLayoutManager.setStackFromEnd(true);
    mPathView.setAdapter(mPathAdapter);
    mPowafulActionMode.setOnSelectionTaskListener(new PowerfulActionMode.OnSelectionTaskListener() {

        @Override
        public void onSelectionTask(boolean started, PowerfulActionMode actionMode) {
            toolbar.setVisibility(!started ? View.VISIBLE : View.GONE);
        }
    });
    mPathAdapter.setOnClickListener(new PathResolverRecyclerAdapter.OnClickListener<String>() {

        @Override
        public void onClick(PathResolverRecyclerAdapter.Holder<String> holder) {
            goPath(holder.index.object);
        }
    });
    mHomeButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            goPath(null);
        }
    });
    if (ACTION_LIST_TRANSFERS.equals(getIntent().getAction()) && getIntent().hasExtra(EXTRA_GROUP_ID)) {
        TransactionObject.Group group = new TransactionObject.Group(getIntent().getIntExtra(EXTRA_GROUP_ID, -1));
        try {
            mDatabase.reconstruct(group);
            NetworkDevice networkDevice = new NetworkDevice(group.deviceId);
            mDatabase.reconstruct(networkDevice);
            mGroup = group;
            mDevice = networkDevice;
            mInfoDialog = new TransactionGroupInfoDialog(this, mDatabase, mGroup);
            if (getSupportActionBar() != null)
                getSupportActionBar().setTitle(mDevice.nickname);
            mTransactionFragment.getAdapter().setPathChangedListener(this);
            applyPath(null);
            View headerView = mNavigationView.getHeaderView(0);
            View layoutView = headerView.findViewById(R.id.header_default_device_container);
            ImageView imageView = headerView.findViewById(R.id.header_default_device_image);
            TextView deviceNameText = headerView.findViewById(R.id.header_default_device_name_text);
            TextView versionText = headerView.findViewById(R.id.header_default_device_version_text);
            String firstLetters = TextUtils.getFirstLetters(mDevice.nickname, 1);
            TextDrawable drawable = TextDrawable.builder().buildRoundRect(firstLetters.length() > 0 ? firstLetters : "?", ContextCompat.getColor(getApplicationContext(), R.color.networkDeviceRipple), 100);
            layoutView.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    new DeviceInfoDialog(TransactionActivity.this, mDatabase, mDevice).show();
                    if (mDrawerLayout != null)
                        mDrawerLayout.closeDrawer(Gravity.START);
                }
            });
            imageView.setImageDrawable(drawable);
            deviceNameText.setText(mDevice.nickname);
            versionText.setText(mDevice.versionName);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    if (mGroup == null)
        finish();
}
Also used : TextDrawable(com.amulyakhare.textdrawable.TextDrawable) NetworkDevice(com.genonbeta.TrebleShot.object.NetworkDevice) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TransactionObject(com.genonbeta.TrebleShot.object.TransactionObject) TransactionGroupInfoDialog(com.genonbeta.TrebleShot.dialog.TransactionGroupInfoDialog) TextView(android.widget.TextView) ImageView(android.widget.ImageView) Toolbar(android.support.v7.widget.Toolbar) PowerfulActionMode(com.genonbeta.TrebleShot.widget.PowerfulActionMode) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) IOException(java.io.IOException) PathResolverRecyclerAdapter(com.genonbeta.TrebleShot.adapter.PathResolverRecyclerAdapter) DeviceInfoDialog(com.genonbeta.TrebleShot.dialog.DeviceInfoDialog) AccessDatabase(com.genonbeta.TrebleShot.database.AccessDatabase)

Example 97 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project TrebleShot by genonbeta.

the class HomeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mDrawerLayout = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.text_navigationDrawerOpen, R.string.text_navigationDrawerClose);
    mDrawerLayout.addDrawerListener(toggle);
    toggle.syncState();
    mUpdater = new GitHubUpdater(this, AppConfig.URI_REPO_APP_UPDATE, R.style.AppTheme);
    mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mActionMode = findViewById(R.id.content_powerful_action_mode);
    mNavigationView = findViewById(R.id.nav_view);
    mFAB = findViewById(R.id.content_fab);
    mNavigationView.setNavigationItemSelectedListener(this);
    mFragmentDeviceList = Fragment.instantiate(this, NetworkDeviceListFragment.class.getName());
    mFragmentFileExplorer = Fragment.instantiate(this, FileExplorerFragment.class.getName());
    mFragmentTransactions = Fragment.instantiate(this, TransactionGroupListFragment.class.getName());
    mFragmentShareApp = Fragment.instantiate(this, ApplicationListFragment.class.getName());
    mFragmentShareImage = Fragment.instantiate(this, ImageListFragment.class.getName());
    mFragmentShareMusic = Fragment.instantiate(this, MusicListFragment.class.getName());
    mFragmentShareVideo = Fragment.instantiate(this, VideoListFragment.class.getName());
    mFragmentShareText = Fragment.instantiate(this, TextStreamListFragment.class.getName());
    mActionMode.setOnSelectionTaskListener(new PowerfulActionMode.OnSelectionTaskListener() {

        @Override
        public void onSelectionTask(boolean started, PowerfulActionMode actionMode) {
            toolbar.setVisibility(!started ? View.VISIBLE : View.GONE);
        }
    });
    if (mPreferences.contains("availableVersion") && mUpdater.isNewVersion(mPreferences.getString("availableVersion", null))) {
        highlightUpdater(mPreferences.getString("availableVersion", null));
    } else {
        mUpdater.checkForUpdates(false, new GitHubUpdater.OnInfoAvailableListener() {

            @Override
            public void onInfoAvailable(boolean newVersion, String versionName, String title, String description, String releaseDate) {
                mPreferences.edit().putString("availableVersion", versionName).apply();
                if (newVersion)
                    highlightUpdater(versionName);
            }
        });
    }
    NetworkDevice localDevice = AppUtils.getLocalDevice(getApplicationContext());
    if (mPreferences.getInt("migrated_version", localDevice.versionNumber) < localDevice.versionNumber) {
    // migrating to a new version
    }
    mPreferences.edit().putInt("migrated_version", localDevice.versionNumber).apply();
    if (!checkRequestedFragment(getIntent()) && !restorePreviousFragment()) {
        changeFragment(mFragmentDeviceList);
        mNavigationView.setCheckedItem(R.id.menu_activity_main_device_list);
    }
}
Also used : PowerfulActionMode(com.genonbeta.TrebleShot.widget.PowerfulActionMode) GitHubUpdater(velitasali.updatewithgithub.GitHubUpdater) NetworkDevice(com.genonbeta.TrebleShot.object.NetworkDevice) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Toolbar(android.support.v7.widget.Toolbar)

Example 98 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project silverblog_android by SilverBlogTeam.

the class post_list_card_Activity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String host_save;
    String password_save;
    sharedPreferences = getSharedPreferences("data", MODE_PRIVATE);
    host_save = sharedPreferences.getString("host", null);
    password_save = sharedPreferences.getString("password", null);
    if (password_save == null || host_save == null) {
        start_login();
        return;
    }
    if (host_save.contains("http://")) {
        String testip = host_save.replace("http://", "");
        if (testip.endsWith("/")) {
            testip = testip.replace("/", "");
        }
        if (!isip(testip)) {
            host_save = host_save.replace("http://", "https://");
        }
    }
    public_value.host = host_save;
    public_value.password = password_save;
    setContentView(R.layout.activity_post_list_card);
    toolbar = findViewById(R.id.toolbar);
    toolbar.setTitle("Loading...");
    setSupportActionBar(toolbar);
    context = getApplicationContext();
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    if (Intent.ACTION_SEND.equals(action) && type != null) {
        if ("text/plain".equals(type)) {
            Snackbar.make(findViewById(R.id.fab), R.string.share_recive, Snackbar.LENGTH_LONG).show();
            handleSendText(intent);
        }
    }
    recyclerView = findViewById(R.id.my_recycler_view);
    final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setHasFixedSize(true);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    final FloatingActionButton fab = findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent new_post_activity = new Intent(post_list_card_Activity.this, post_Activity.class);
            new_post_activity.putExtra("share_title", public_value.share_title);
            new_post_activity.putExtra("share_text", public_value.share_text);
            public_value.share_text = null;
            public_value.share_title = null;
            startActivity(new_post_activity);
        }
    });
    DrawerLayout drawer = 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();
    result_receiver receiver = new result_receiver();
    IntentFilter filter = new IntentFilter();
    filter.addAction(MY_BROADCAST_TAG);
    LocalBroadcastManager.getInstance(context).registerReceiver(receiver, filter);
    navigationView = findViewById(R.id.nav_view);
    mSwipeRefreshWidget = findViewById(R.id.swipe_refresh_widget);
    mSwipeRefreshWidget.setColorSchemeResources(R.color.colorPrimary);
    if (host_save != null) {
        mSwipeRefreshWidget.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

            @Override
            public void onRefresh() {
                new get_post_list_content().execute();
                new get_menu_list_content().execute();
            }
        });
        new get_post_list_content().execute();
        new get_menu_list_content().execute();
        new get_system_info_content().execute();
    }
}
Also used : IntentFilter(android.content.IntentFilter) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) FloatingActionButton(android.support.design.widget.FloatingActionButton) DrawerLayout(android.support.v4.widget.DrawerLayout)

Example 99 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project bunk by abhijitparida.

the class AttendanceActivity method setupDrawer.

private void setupDrawer() {
    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    Toolbar toolbar = findViewById(R.id.toolbar);
    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);
    View navigationViewHeader = navigationView.getHeaderView(0);
    ((TextView) navigationViewHeader.findViewById(R.id.name)).setText(mNewStudent.name);
    ((TextView) navigationViewHeader.findViewById(R.id.username)).setText(mNewStudent.username);
    String[] prompts = { "open source?", "coding?", "programming?", "code+coffee?" };
    TextView opensource = drawer.findViewById(R.id.opensource);
    opensource.setText(prompts[new Random().nextInt(prompts.length)]);
    TextView github = drawer.findViewById(R.id.github);
    github.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
    github.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getResources().getString(R.string.url_github))));
        }
    });
}
Also used : NavigationView(android.support.design.widget.NavigationView) Random(java.util.Random) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) TextView(android.widget.TextView) Intent(android.content.Intent) DrawerLayout(android.support.v4.widget.DrawerLayout) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) AdView(com.google.android.gms.ads.AdView) TextView(android.widget.TextView) ListView(android.widget.ListView) Toolbar(android.support.v7.widget.Toolbar)

Example 100 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project UdacityForum by collaborateudacity.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    drawerLayout = (DrawerLayout) findViewById(R.id.nav_drawer);
    setSupportActionBar(toolbar);
    actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.open_drawer, R.string.close_drawer);
    drawerLayout.addDrawerListener(actionBarDrawerToggle);
    ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT, Gravity.CENTER);
    actionBarView = LayoutInflater.from(this).inflate(R.layout.actionbar_custom_view, null);
    actionBarTitle = (TextView) actionBarView.findViewById(R.id.tv_heading);
    actionBarTitle.setText(getString(R.string.activity_name));
    actionBar = getSupportActionBar();
    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    getSupportActionBar().setCustomView(actionBarView, params);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) ActionBar(android.support.v7.app.ActionBar)

Aggregations

ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)218 View (android.view.View)153 NavigationView (android.support.design.widget.NavigationView)118 Toolbar (android.support.v7.widget.Toolbar)98 DrawerLayout (android.support.v4.widget.DrawerLayout)96 TextView (android.widget.TextView)85 AdapterView (android.widget.AdapterView)51 ImageView (android.widget.ImageView)48 ListView (android.widget.ListView)48 Intent (android.content.Intent)45 ActionBarDrawerToggle (android.support.v4.app.ActionBarDrawerToggle)35 ActionBar (android.support.v7.app.ActionBar)31 SharedPreferences (android.content.SharedPreferences)30 RecyclerView (android.support.v7.widget.RecyclerView)23 Bundle (android.os.Bundle)20 FloatingActionButton (android.support.design.widget.FloatingActionButton)20 LinearLayout (android.widget.LinearLayout)19 MenuItem (android.view.MenuItem)17 BindView (butterknife.BindView)15 ArrayList (java.util.ArrayList)15