use of com.google.android.material.floatingactionbutton.FloatingActionButton in project Gadgetbridge by Freeyourgadget.
the class ActivitySummariesActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
Bundle extras = getIntent().getExtras();
if (extras != null) {
mGBDevice = extras.getParcelable(GBDevice.EXTRA_DEVICE);
} else {
throw new IllegalArgumentException("Must provide a device when invoking this activity");
}
deviceFilter = getDeviceId(mGBDevice);
IntentFilter filterLocal = new IntentFilter();
filterLocal.addAction(GBDevice.ACTION_DEVICE_CHANGED);
LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filterLocal);
super.onCreate(savedInstanceState);
ActivitySummariesAdapter activitySummariesAdapter = new ActivitySummariesAdapter(this, mGBDevice, activityFilter, dateFromFilter, dateToFilter, nameContainsFilter, deviceFilter, itemsFilter);
int backgroundColor = getBackgroundColor(ActivitySummariesActivity.this);
activitySummariesAdapter.setBackgroundColor(backgroundColor);
activitySummariesAdapter.setShowTime(false);
setItemAdapter(activitySummariesAdapter);
getItemListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// item 0 is empty for dashboard
if (position == 0)
return;
Object item = parent.getItemAtPosition(position);
if (item != null) {
ActivitySummary summary = (ActivitySummary) item;
try {
showActivityDetail(position);
} catch (Exception e) {
GB.toast(getApplicationContext(), "Unable to display Activity Detail, maybe the activity is not available yet: " + e.getMessage(), Toast.LENGTH_LONG, GB.ERROR, e);
}
}
}
});
getItemListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
getItemListView().setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
@Override
public void onItemCheckedStateChanged(ActionMode actionMode, int position, long id, boolean checked) {
if (position == 0 && checked)
subtrackDashboard = 1;
if (position == 0 && !checked)
subtrackDashboard = 0;
final int selectedItems = getItemListView().getCheckedItemCount() - subtrackDashboard;
actionMode.setTitle(selectedItems + " selected");
}
@Override
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
getMenuInflater().inflate(R.menu.activity_list_context_menu, menu);
findViewById(R.id.fab).setVisibility(View.INVISIBLE);
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
return false;
}
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
boolean processed = false;
SparseBooleanArray checked = getItemListView().getCheckedItemPositions();
switch(menuItem.getItemId()) {
case R.id.activity_action_delete:
List<BaseActivitySummary> toDelete = new ArrayList<>();
for (int i = 0; i < checked.size(); i++) {
if (checked.valueAt(i)) {
toDelete.add(getItemAdapter().getItem(checked.keyAt(i)));
}
}
deleteItems(toDelete);
processed = true;
break;
case R.id.activity_action_export:
List<String> paths = new ArrayList<>();
for (int i = 0; i < checked.size(); i++) {
if (checked.valueAt(i)) {
BaseActivitySummary item = getItemAdapter().getItem(checked.keyAt(i));
if (item != null) {
ActivitySummary summary = item;
String gpxTrack = summary.getGpxTrack();
if (gpxTrack != null) {
paths.add(gpxTrack);
}
}
}
}
shareMultiple(paths);
processed = true;
break;
case R.id.activity_action_select_all:
for (int i = 0; i < getItemListView().getCount(); i++) {
getItemListView().setItemChecked(i, true);
}
// don't finish actionmode in this case!
return true;
case R.id.activity_action_addto_filter:
List<Long> toFilter = new ArrayList<>();
for (int i = 0; i < checked.size(); i++) {
if (checked.valueAt(i)) {
BaseActivitySummary item = getItemAdapter().getItem(checked.keyAt(i));
if (item != null && item.getId() != null) {
ActivitySummary summary = item;
Long id = summary.getId();
toFilter.add(id);
}
}
}
itemsFilter = toFilter;
setItemsFilter(itemsFilter);
refresh();
processed = true;
break;
default:
break;
}
actionMode.finish();
return processed;
}
@Override
public void onDestroyActionMode(ActionMode actionMode) {
findViewById(R.id.fab).setVisibility(View.VISIBLE);
}
});
swipeLayout = findViewById(R.id.list_activity_swipe_layout);
swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
fetchTrackData();
}
});
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
fetchTrackData();
}
});
activityKindMap = fillKindMap();
}
use of com.google.android.material.floatingactionbutton.FloatingActionButton in project IITB-App by wncc.
the class MapFragment method setupWithData.
private void setupWithData(List<Venue> venues) {
if (getActivity() == null || getView() == null || getContext() == null)
return;
// Setup fade animation for background
int colorFrom = Utils.getAttrColor(getContext(), R.attr.themeColor);
int colorTo = getResources().getColor(R.color.colorGray);
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
// milliseconds
colorAnimation.setDuration(250);
colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
if (getActivity() == null || getView() == null)
return;
getView().findViewById(R.id.main_container).setBackgroundColor((int) animator.getAnimatedValue());
}
});
colorAnimation.start();
// Show the location fab
if (getView() == null)
return;
((FloatingActionButton) getView().findViewById(R.id.locate_fab)).show();
// Start the setup
Locations mLocations = new Locations(venues);
data = mLocations.data;
markerlist = new ArrayList<>(data.values());
if (getArguments() != null) {
setupMap(getArguments().getString(Constants.MAP_INITIAL_MARKER));
}
// Setup locate button
FloatingActionButton fab = getView().findViewById(R.id.locate_fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
locate(true);
}
});
// Setup GPS if already has permission and GPS is on
String permission = Manifest.permission.ACCESS_FINE_LOCATION;
int res = getContext().checkCallingOrSelfPermission(permission);
if (res == PackageManager.PERMISSION_GRANTED) {
final LocationManager manager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
if (manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
locate(false);
setFollowingUser(false);
}
}
}
use of com.google.android.material.floatingactionbutton.FloatingActionButton in project collect by opendatakit.
the class DrawActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.draw_layout);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
fabActions = findViewById(R.id.fab_actions);
final FloatingActionButton fabSetColor = findViewById(R.id.fab_set_color);
final CardView cardViewSetColor = findViewById(R.id.cv_set_color);
final FloatingActionButton fabSaveAndClose = findViewById(R.id.fab_save_and_close);
final CardView cardViewSaveAndClose = findViewById(R.id.cv_save_and_close);
final FloatingActionButton fabClear = findViewById(R.id.fab_clear);
final CardView cardViewClear = findViewById(R.id.cv_clear);
fabActions.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int status = Integer.parseInt(view.getTag().toString());
if (status == 0) {
status = 1;
fabActions.animate().rotation(45).setInterpolator(new AccelerateDecelerateInterpolator()).setDuration(100).start();
AnimationUtils.scaleInAnimation(fabSetColor, 50, 150, new OvershootInterpolator(), true);
AnimationUtils.scaleInAnimation(cardViewSetColor, 50, 150, new OvershootInterpolator(), true);
AnimationUtils.scaleInAnimation(fabSaveAndClose, 100, 150, new OvershootInterpolator(), true);
AnimationUtils.scaleInAnimation(cardViewSaveAndClose, 100, 150, new OvershootInterpolator(), true);
AnimationUtils.scaleInAnimation(fabClear, 150, 150, new OvershootInterpolator(), true);
AnimationUtils.scaleInAnimation(cardViewClear, 150, 150, new OvershootInterpolator(), true);
fabSetColor.show();
cardViewSetColor.setVisibility(View.VISIBLE);
fabSaveAndClose.show();
cardViewSaveAndClose.setVisibility(View.VISIBLE);
fabClear.show();
cardViewClear.setVisibility(View.VISIBLE);
} else {
status = 0;
fabActions.animate().rotation(0).setInterpolator(new AccelerateDecelerateInterpolator()).setDuration(100).start();
fabSetColor.hide();
cardViewSetColor.setVisibility(View.INVISIBLE);
fabSaveAndClose.hide();
cardViewSaveAndClose.setVisibility(View.INVISIBLE);
fabClear.hide();
cardViewClear.setVisibility(View.INVISIBLE);
}
view.setTag(status);
}
});
cardViewClear.setOnClickListener(this::clear);
fabClear.setOnClickListener(this::clear);
cardViewSaveAndClose.setOnClickListener(this::close);
fabSaveAndClose.setOnClickListener(this::close);
cardViewSetColor.setOnClickListener(this::setColor);
fabSetColor.setOnClickListener(this::setColor);
Bundle extras = getIntent().getExtras();
StoragePathProvider storagePathProvider = new StoragePathProvider();
if (extras == null) {
loadOption = OPTION_DRAW;
refImage = null;
savepointImage = new File(storagePathProvider.getTmpImageFilePath());
savepointImage.delete();
output = new File(storagePathProvider.getTmpImageFilePath());
} else {
if (extras.getInt(SCREEN_ORIENTATION) == 1) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
loadOption = extras.getString(OPTION);
if (loadOption == null) {
loadOption = OPTION_DRAW;
}
// refImage can also be present if resuming a drawing
Uri uri = (Uri) extras.get(REF_IMAGE);
if (uri != null) {
refImage = new File(uri.getPath());
}
String savepoint = extras.getString(SAVEPOINT_IMAGE);
if (savepoint != null) {
savepointImage = new File(savepoint);
if (!savepointImage.exists() && refImage != null && refImage.exists()) {
ImageFileUtils.copyImageAndApplyExifRotation(refImage, savepointImage);
}
} else {
savepointImage = new File(storagePathProvider.getTmpImageFilePath());
savepointImage.delete();
if (refImage != null && refImage.exists()) {
ImageFileUtils.copyImageAndApplyExifRotation(refImage, savepointImage);
}
}
uri = (Uri) extras.get(EXTRA_OUTPUT);
if (uri != null) {
output = new File(uri.getPath());
} else {
output = new File(storagePathProvider.getTmpImageFilePath());
}
}
if (OPTION_SIGNATURE.equals(loadOption)) {
alertTitleString = getString(R.string.quit_application, getString(R.string.sign_button));
} else if (OPTION_ANNOTATE.equals(loadOption)) {
alertTitleString = getString(R.string.quit_application, getString(R.string.markup_image));
} else {
alertTitleString = getString(R.string.quit_application, getString(R.string.draw_image));
}
drawView = findViewById(R.id.drawView);
drawView.setupView(OPTION_SIGNATURE.equals(loadOption));
}
use of com.google.android.material.floatingactionbutton.FloatingActionButton in project ToyShark by LipiLee.
the class DetailActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
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();
}
});
final ActionBar back = getSupportActionBar();
if (back != null) {
back.setDisplayHomeAsUpEnabled(true);
}
}
use of com.google.android.material.floatingactionbutton.FloatingActionButton in project mapbox-plugins-android by mapbox.
the class DynamicSymbolChangeActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_annotation);
mapView = findViewById(R.id.mapView);
mapView.setTag(false);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> {
DynamicSymbolChangeActivity.this.mapboxMap = mapboxMap;
LatLng target = new LatLng(51.506675, -0.128699);
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder().bearing(90).tilt(40).zoom(10).target(target).build()));
mapboxMap.setStyle(new Style.Builder().fromUri(Style.MAPBOX_STREETS).withImage(ID_ICON_1, generateBitmap(R.drawable.mapbox_ic_place), true).withImage(ID_ICON_2, generateBitmap(R.drawable.mapbox_ic_offline), true), style -> {
symbolManager = new SymbolManager(mapView, mapboxMap, style);
symbolManager.setIconAllowOverlap(true);
symbolManager.setTextAllowOverlap(true);
// Create Symbol
SymbolOptions SymbolOptions = new SymbolOptions().withLatLng(LAT_LNG_CHELSEA).withIconImage(ID_ICON_1);
symbol = symbolManager.create(SymbolOptions);
});
});
FloatingActionButton fab = findViewById(R.id.fabStyles);
fab.setVisibility(MapView.VISIBLE);
fab.setOnClickListener(view -> {
if (mapboxMap != null) {
updateSymbol();
}
});
}
Aggregations