use of jahirfiquitiva.libs.fabsmenu.TitleFAB in project FABsMenu by jahirfiquitiva.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
setContentView(R.layout.activity_main);
Button snackButton = findViewById(R.id.snack_button);
snackButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(findViewById(R.id.coordinator), "Testing, testing, 1, 2, 3", Snackbar.LENGTH_LONG).show();
}
});
RecyclerView rv = findViewById(R.id.rv);
rv.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
rv.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
rv.setAdapter(new SampleAdapter(this));
menu = findViewById(R.id.fabs_menu);
menu.attachToRecyclerView(rv);
menu.setMenuListener(new FABsMenuListener() {
// You don't need to override all methods. Just the ones you want.
@Override
public void onMenuClicked(FABsMenu fabsMenu) {
// Default implementation opens the menu on click
super.onMenuClicked(fabsMenu);
// showToast("You pressed the menu!");
}
@Override
public void onMenuCollapsed(FABsMenu fabsMenu) {
super.onMenuCollapsed(fabsMenu);
// showToast("The menu has been collapsed!");
}
@Override
public void onMenuExpanded(FABsMenu fabsMenu) {
super.onMenuExpanded(fabsMenu);
// showToast("The menu has been expanded!");
}
});
TitleFAB clickableTitle = findViewById(R.id.clickable_title);
clickableTitle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showToast("You pressed the red fab or its title");
}
});
TitleFAB mini = findViewById(R.id.mini_fab);
mini.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showToast("You pressed the mini fab!");
}
});
TitleFAB green = findViewById(R.id.green_fab);
green.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showToast("You pressed the green fab");
}
});
// Removes a button
TitleFAB toRemove = findViewById(R.id.to_remove);
menu.removeButton(toRemove);
// Adds a button to the bottom
final TitleFAB toAdd = new TitleFAB(this);
toAdd.setTitle("A new added fab");
toAdd.setBackgroundColor(Color.parseColor("#ff5722"));
toAdd.setTitleClickEnabled(true);
toAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showToast("You pressed the new button");
toAdd.hide();
}
});
menu.addButton(toAdd);
}
use of jahirfiquitiva.libs.fabsmenu.TitleFAB in project FABsMenu by jahirfiquitiva.
the class MainActivity method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.add) {
final TitleFAB toAdd = new TitleFAB(this);
toAdd.setTitle("A new added fab");
toAdd.setBackgroundColor(Color.parseColor("#ff5722"));
toAdd.setTitleClickEnabled(true);
toAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showToast("You pressed the new button");
toAdd.hide();
}
});
menu.addButton(toAdd);
} else if (item.getItemId() == R.id.remove) {
menu.removeAllButtons();
}
return super.onOptionsItemSelected(item);
}
use of jahirfiquitiva.libs.fabsmenu.TitleFAB in project andOTP by andOTP.
the class MainActivity method onCreate.
// Initialize the main application
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(R.string.app_name);
if (!settings.getScreenshotsEnabled())
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
settings.registerPreferenceChangeListener(this);
encryptionType = settings.getEncryption();
if (settings.getAuthMethod() != AuthMethod.NONE && savedInstanceState == null)
requireAuthentication = true;
setBroadcastCallback(new BroadcastReceivedCallback() {
@Override
public void onReceivedScreenOff() {
if (settings.getRelockOnScreenOff() && settings.getAuthMethod() != AuthMethod.NONE)
requireAuthentication = true;
}
});
if (!settings.getFirstTimeWarningShown()) {
showFirstTimeWarning();
}
fabsMenu = findViewById(R.id.fabs_menu);
TitleFAB qrFAB = findViewById(R.id.fab_qr_scan);
qrFAB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
fabsMenu.collapse();
scanQRCode();
}
});
TitleFAB manualFAB = findViewById(R.id.fab_manual_entry);
manualFAB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
fabsMenu.collapse();
ManualEntryDialog.show(MainActivity.this, settings, adapter);
}
});
final ProgressBar progressBar = findViewById(R.id.progressBar);
RecyclerView recList = findViewById(R.id.cardList);
recList.setHasFixedSize(true);
LinearLayoutManager llm = new LinearLayoutManager(this);
llm.setOrientation(LinearLayoutManager.VERTICAL);
recList.setLayoutManager(llm);
tagsDrawerAdapter = new TagsAdapter(this, new HashMap<String, Boolean>());
adapter = new EntriesCardAdapter(this, tagsDrawerAdapter);
recList.setAdapter(adapter);
touchHelperCallback = new SimpleItemTouchHelperCallback(adapter);
ItemTouchHelper touchHelper = new ItemTouchHelper(touchHelperCallback);
touchHelper.attachToRecyclerView(recList);
NotificationHelper.initializeNotificationChannels(this);
restoreSortMode();
float durationScale = android.provider.Settings.Global.getFloat(this.getContentResolver(), android.provider.Settings.Global.ANIMATOR_DURATION_SCALE, 0);
if (durationScale == 0)
durationScale = 1;
final long animatorDuration = (long) (1000 / durationScale);
adapter.setCallback(new EntriesCardAdapter.Callback() {
@Override
public void onMoveEventStart() {
stopUpdater();
}
@Override
public void onMoveEventStop() {
startUpdater();
}
});
handler = new Handler();
handlerTask = new Runnable() {
@Override
public void run() {
int progress = (int) (TokenCalculator.TOTP_DEFAULT_PERIOD - (System.currentTimeMillis() / 1000) % TokenCalculator.TOTP_DEFAULT_PERIOD);
progressBar.setProgress(progress * 100);
ObjectAnimator animation = ObjectAnimator.ofInt(progressBar, "progress", (progress - 1) * 100);
animation.setDuration(animatorDuration);
animation.setInterpolator(new LinearInterpolator());
animation.start();
adapter.updateTokens();
handler.postDelayed(this, 1000);
}
};
setupDrawer();
}
Aggregations