Commit 33caa649 authored by Varun Patil's avatar Varun Patil

Add animation to opening map background

parent 330a040c
package app.insti.fragment;
import android.Manifest;
import android.animation.ArgbEvaluator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.PointF;
import android.graphics.Typeface;
......@@ -37,6 +40,7 @@ import android.text.style.ClickableSpan;
import android.text.style.StyleSpan;
import android.text.util.Linkify;
import android.util.Log;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MenuItem;
......@@ -235,6 +239,29 @@ public class MapFragment extends Fragment implements TextWatcher,
@Override
public void onResponse(Call<List<Venue>> call, Response<List<Venue>> response) {
if (response.isSuccessful()) {
// Setup fade animation for background
TypedValue typedValue = new TypedValue();
Resources.Theme theme = getContext().getTheme();
theme.resolveAttribute(R.attr.themeColor, typedValue, true);
int colorFrom = typedValue.data;
int colorTo = getResources().getColor(R.color.colorGray);
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
colorAnimation.setDuration(250); // milliseconds
colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
getView().findViewById(R.id.main_container).setBackgroundColor(
(int) animator.getAnimatedValue()
);
}
});
colorAnimation.start();
// Show the location fab
((FloatingActionButton) getView().findViewById(R.id.locate_fab)).show();
// Show the map and data
setupWithData(response.body());
}
}
......
......@@ -33,18 +33,11 @@
android:id="@+id/main_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/darker_gray"
android:focusable="true"
android:focusableInTouchMode="true"
tools:context="com.mrane.campusmap.MainActivity"
tools:ignore="MergeRootFrame">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"></LinearLayout>
<com.mrane.navigation.SlidingUpPanelLayout
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
......@@ -90,7 +83,8 @@
android:layout_marginBottom="96dp"
android:layout_marginRight="8dp"
android:src="@drawable/ic_my_location_black_24dp"
android:tint="@android:color/black" />
android:tint="@android:color/black"
android:visibility="invisible" />
</RelativeLayout>
</FrameLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment