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