Apostolos Fanakis
6 years ago
17 changed files with 218 additions and 11 deletions
@ -0,0 +1,49 @@ |
|||||
|
package gr.auth.databases.flavours.activities.restaurant; |
||||
|
|
||||
|
import android.os.Bundle; |
||||
|
import android.view.MenuItem; |
||||
|
|
||||
|
import androidx.appcompat.app.ActionBar; |
||||
|
import androidx.appcompat.widget.Toolbar; |
||||
|
import gr.auth.databases.flavours.R; |
||||
|
import gr.auth.databases.flavours.base.BaseActivity; |
||||
|
|
||||
|
public class AddRestaurantActivity extends BaseActivity { |
||||
|
|
||||
|
@Override |
||||
|
protected void onCreate(Bundle savedInstanceState) { |
||||
|
super.onCreate(savedInstanceState); |
||||
|
setContentView(R.layout.activity_main); |
||||
|
|
||||
|
Toolbar toolbar = findViewById(R.id.main_toolbar); |
||||
|
toolbar.setTitle("Add Restaurant"); |
||||
|
setSupportActionBar(toolbar); |
||||
|
ActionBar actionbar = getSupportActionBar(); |
||||
|
actionbar.setDisplayHomeAsUpEnabled(true); |
||||
|
actionbar.setHomeAsUpIndicator(R.drawable.ic_menu_black_24dp); |
||||
|
|
||||
|
createDrawer(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onBackPressed() { |
||||
|
if (drawer.isDrawerOpen()) { |
||||
|
drawer.closeDrawer(); |
||||
|
} else { |
||||
|
super.onBackPressed(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public boolean onOptionsItemSelected(MenuItem item) { |
||||
|
int id = item.getItemId(); |
||||
|
|
||||
|
if (id == android.R.id.home) { |
||||
|
drawer.openDrawer(); |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
return super.onOptionsItemSelected(item); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package gr.auth.databases.flavours.activities.restaurant; |
||||
|
|
||||
|
import gr.auth.databases.flavours.R; |
||||
|
import gr.auth.databases.flavours.base.BaseActivity; |
||||
|
|
||||
|
import android.os.Bundle; |
||||
|
|
||||
|
public class RestaurantActivity extends BaseActivity { |
||||
|
|
||||
|
@Override |
||||
|
protected void onCreate(Bundle savedInstanceState) { |
||||
|
super.onCreate(savedInstanceState); |
||||
|
setContentView(R.layout.activity_restaurant); |
||||
|
} |
||||
|
} |
@ -0,0 +1,63 @@ |
|||||
|
package gr.auth.databases.flavours.utils; |
||||
|
|
||||
|
import android.content.Context; |
||||
|
import android.util.AttributeSet; |
||||
|
import android.view.View; |
||||
|
|
||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton; |
||||
|
import com.google.android.material.snackbar.Snackbar; |
||||
|
|
||||
|
import androidx.annotation.NonNull; |
||||
|
import androidx.coordinatorlayout.widget.CoordinatorLayout; |
||||
|
import androidx.core.view.ViewCompat; |
||||
|
|
||||
|
@SuppressWarnings("unused") |
||||
|
public class ScrollAwareFABBehavior extends CoordinatorLayout.Behavior<FloatingActionButton> { |
||||
|
|
||||
|
public ScrollAwareFABBehavior(Context context, AttributeSet attrs) { |
||||
|
super(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public boolean onStartNestedScroll(@NonNull final CoordinatorLayout coordinatorLayout, |
||||
|
@NonNull final FloatingActionButton child, |
||||
|
@NonNull final View directTargetChild, @NonNull final View target, |
||||
|
final int nestedScrollAxes, int type) { |
||||
|
return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onNestedScroll(@NonNull final CoordinatorLayout coordinatorLayout, |
||||
|
@NonNull final FloatingActionButton child, |
||||
|
@NonNull final View target, final int dxConsumed, final int dyConsumed, |
||||
|
final int dxUnconsumed, final int dyUnconsumed, int type) { |
||||
|
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, |
||||
|
dyUnconsumed, type); |
||||
|
if (dyConsumed > 0 || (!target.canScrollVertically(-1) && dyConsumed == 0 && dyUnconsumed > 50)) { |
||||
|
child.hide(new FloatingActionButton.OnVisibilityChangedListener() { |
||||
|
@Override |
||||
|
public void onHidden(FloatingActionButton fab) { |
||||
|
super.onHidden(fab); |
||||
|
fab.setVisibility(View.INVISIBLE); |
||||
|
} |
||||
|
}); |
||||
|
} else if (dyConsumed < 0 || !target.canScrollVertically(-1) && dyUnconsumed < -50) { |
||||
|
child.show(); |
||||
|
child.setVisibility(View.VISIBLE); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public boolean layoutDependsOn(@NonNull CoordinatorLayout parent, |
||||
|
@NonNull FloatingActionButton child, @NonNull View dependency) { |
||||
|
return dependency instanceof Snackbar.SnackbarLayout; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public boolean onDependentViewChanged(@NonNull CoordinatorLayout parent, |
||||
|
@NonNull FloatingActionButton child, @NonNull View dependency) { |
||||
|
float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight()); |
||||
|
child.setTranslationY(translationY); |
||||
|
return true; |
||||
|
} |
||||
|
} |
After Width: | Height: | Size: 156 B |
After Width: | Height: | Size: 103 B |
After Width: | Height: | Size: 135 B |
After Width: | Height: | Size: 180 B |
After Width: | Height: | Size: 243 B |
@ -0,0 +1,23 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
|
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="match_parent" |
||||
|
android:background="@android:color/background_light" |
||||
|
android:fitsSystemWindows="true"> |
||||
|
|
||||
|
<com.google.android.material.appbar.AppBarLayout |
||||
|
android:id="@+id/add_restaurant_appbar" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:theme="@style/Theme.AppCompat.Light"> |
||||
|
|
||||
|
<androidx.appcompat.widget.Toolbar |
||||
|
android:id="@+id/add_restaurant_toolbar" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="?attr/actionBarSize" |
||||
|
android:background="?attr/colorPrimary" |
||||
|
app:popupTheme="@style/Theme.AppCompat.Light" /> |
||||
|
</com.google.android.material.appbar.AppBarLayout> |
||||
|
|
||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout> |
@ -0,0 +1,37 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
|
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="match_parent" |
||||
|
android:background="@android:color/background_light" |
||||
|
android:fitsSystemWindows="true"> |
||||
|
|
||||
|
<com.google.android.material.appbar.AppBarLayout |
||||
|
android:id="@+id/restaurant_appbar" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:theme="@style/Theme.AppCompat.Light"> |
||||
|
|
||||
|
<androidx.appcompat.widget.Toolbar |
||||
|
android:id="@+id/restaurant_toolbar" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="?attr/actionBarSize" |
||||
|
android:background="?attr/colorPrimary" |
||||
|
app:popupTheme="@style/Theme.AppCompat.Light" /> |
||||
|
</com.google.android.material.appbar.AppBarLayout> |
||||
|
|
||||
|
<androidx.core.widget.NestedScrollView |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="wrap_content" |
||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"> |
||||
|
|
||||
|
<LinearLayout |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="wrap_content"> |
||||
|
|
||||
|
<TextView |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="wrap_content" /> |
||||
|
</LinearLayout> |
||||
|
</androidx.core.widget.NestedScrollView> |
||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout> |
@ -1,8 +1,10 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
<?xml version="1.0" encoding="utf-8"?> |
||||
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" |
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" |
||||
|
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
android:id="@+id/main_recycler" |
android:id="@+id/main_recycler" |
||||
android:layout_width="match_parent" |
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
android:layout_height="wrap_content" |
||||
android:layout_marginStart="12dp" |
android:layout_marginStart="12dp" |
||||
android:layout_marginEnd="12dp" |
android:layout_marginEnd="12dp" |
||||
android:orientation="vertical" /> |
android:orientation="vertical" |
||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> |
Loading…
Reference in new issue