Permalink
Browse files

Improvement: Replace Croutons with new Snackbar implementation. #365

  • Loading branch information...
1 parent d3d933a commit f439412256e44127a61cdce7932abe9754ce3ec4 @PareshMayani PareshMayani committed Jul 12, 2015
View
@@ -200,9 +200,7 @@ dependencies {
compile 'org.jsoup:jsoup:1.8.2'
compile 'net.danlew:android.joda:2.7.2'
compile 'com.google.code.findbugs:jsr305:2.0.1'
- compile ('de.keyboardsurfer.android.widget:crouton:1.8.5') {
- exclude module: 'support-v4'
- }
+
compile('com.crashlytics.sdk.android:crashlytics:2.2.4@aar') {
transitive = true;
}
@@ -19,6 +19,7 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
+import android.support.design.widget.Snackbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -35,11 +36,10 @@
import org.gdg.frisbee.android.cache.ModelCache;
import org.gdg.frisbee.android.common.GdgListFragment;
import org.gdg.frisbee.android.utils.Utils;
+import org.gdg.frisbee.android.view.ColoredSnackBar;
import org.joda.time.DateTime;
import butterknife.ButterKnife;
-import de.keyboardsurfer.android.widget.crouton.Crouton;
-import de.keyboardsurfer.android.widget.crouton.Style;
import retrofit.Callback;
import retrofit.RestAdapter;
import retrofit.RetrofitError;
@@ -82,15 +82,16 @@ protected void loadContributors() {
public void onGet(Object item) {
ContributorList contributors = (ContributorList) item;
- Crouton.makeText(getActivity(), R.string.cached_content,
- Style.INFO, R.id.content_frame).show();
+ Snackbar snackbar = Snackbar.make(getView(), R.string.cached_content, Snackbar.LENGTH_SHORT);
+ ColoredSnackBar.alert(snackbar).show();
mAdapter.addAll(contributors);
}
@Override
public void onNotFound(String key) {
- Crouton.makeText(getActivity(), R.string.offline_alert,
- Style.ALERT, R.id.content_frame).show();
+ Snackbar snackbar = Snackbar.make(getView(), R.string.offline_alert, Snackbar.LENGTH_SHORT);
+ ColoredSnackBar.alert(snackbar).show();
+
}
});
}
@@ -19,6 +19,7 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
+import android.support.design.widget.Snackbar;
import android.text.Html;
import android.text.Spanned;
import android.text.SpannedString;
@@ -43,14 +44,13 @@
import org.gdg.frisbee.android.task.Builder;
import org.gdg.frisbee.android.task.CommonAsyncTask;
import org.gdg.frisbee.android.utils.Utils;
+import org.gdg.frisbee.android.view.ColoredSnackBar;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import butterknife.ButterKnife;
import butterknife.InjectView;
-import de.keyboardsurfer.android.widget.crouton.Crouton;
-import de.keyboardsurfer.android.widget.crouton.Style;
import timber.log.Timber;
public class InfoFragment extends BaseFragment {
@@ -177,17 +177,20 @@ public void onNotFound(String key) {
}
});
} catch (Exception ex) {
- Crouton.makeText(getActivity(), getString(R.string.bogus_organizer, org),
- Style.ALERT, R.id.content_frame);
+
+ Snackbar snackbar = Snackbar.make(getView(), getString(R.string.bogus_organizer, org),
+ Snackbar.LENGTH_SHORT);
+ ColoredSnackBar.alert(snackbar).show();
}
}
}
}
@Override
public void onNotFound(String key) {
- Crouton.makeText(getActivity(), R.string.offline_alert,
- Style.ALERT, R.id.content_frame).show();
+ Snackbar snackbar = Snackbar.make(getView(), R.string.offline_alert,
+ Snackbar.LENGTH_SHORT);
+ ColoredSnackBar.alert(snackbar).show();
}
});
}
@@ -257,8 +260,9 @@ private void updateOrganizersOnline(final Person person) {
mFetchOrganizerInfo.addParameter(organizerParameter);
} catch (Exception ex) {
if (isAdded()) {
- Crouton.makeText(getActivity(), getString(R.string.bogus_organizer, org),
- Style.ALERT, R.id.content_frame);
+ Snackbar snackbar = Snackbar.make(getView(), getString(R.string.bogus_organizer, org),
+ Snackbar.LENGTH_SHORT);
+ ColoredSnackBar.alert(snackbar).show();
}
}
}
@@ -21,6 +21,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
+import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
@@ -31,6 +32,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
+import android.widget.FrameLayout;
import android.widget.Spinner;
import com.google.android.gms.common.ConnectionResult;
@@ -48,6 +50,7 @@
import org.gdg.frisbee.android.onboarding.FirstStartActivity;
import org.gdg.frisbee.android.utils.PrefUtils;
import org.gdg.frisbee.android.utils.Utils;
+import org.gdg.frisbee.android.view.ColoredSnackBar;
import org.gdg.frisbee.android.widget.SlidingTabLayout;
import org.joda.time.DateTime;
@@ -56,8 +59,6 @@
import java.util.List;
import butterknife.InjectView;
-import de.keyboardsurfer.android.widget.crouton.Crouton;
-import de.keyboardsurfer.android.widget.crouton.Style;
import retrofit.Callback;
import retrofit.RetrofitError;
import timber.log.Timber;
@@ -91,6 +92,9 @@
private ChapterComparator mLocationComparator;
private Spinner mSpinner;
+ @InjectView(R.id.content_frame)
+ FrameLayout mContentFrameLayout;
+
/**
* Called when the activity is first created.
*
@@ -138,8 +142,9 @@ public void onNotFound(String key) {
if (Utils.isOnline(MainActivity.this)) {
fetchChapters();
} else {
- Crouton.makeText(MainActivity.this, getString(R.string.offline_alert),
- Style.ALERT, R.id.content_frame).show();
+ Snackbar snackbar = Snackbar.make(mContentFrameLayout, getString(R.string.offline_alert),
+ Snackbar.LENGTH_SHORT);
+ ColoredSnackBar.alert(snackbar).show();
}
}
});
@@ -265,8 +270,9 @@ public void onPutIntoCache() {
public void failure(RetrofitError error) {
try {
- Crouton.makeText(MainActivity.this, R.string.fetch_chapters_failed,
- Style.ALERT, R.id.content_frame).show();
+ Snackbar snackbar = Snackbar.make(mContentFrameLayout, getString(R.string.fetch_chapters_failed),
+ Snackbar.LENGTH_SHORT);
+ ColoredSnackBar.alert(snackbar).show();
} catch (IllegalStateException exception) {
}
Timber.e(error, "Couldn't fetch chapter list");
@@ -17,6 +17,7 @@
package org.gdg.frisbee.android.chapter;
import android.os.Bundle;
+import android.support.design.widget.Snackbar;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
@@ -41,13 +42,13 @@
import org.gdg.frisbee.android.task.Builder;
import org.gdg.frisbee.android.task.CommonAsyncTask;
import org.gdg.frisbee.android.utils.Utils;
+import org.gdg.frisbee.android.view.ColoredSnackBar;
import org.joda.time.DateTime;
import java.io.IOException;
import butterknife.ButterKnife;
-import de.keyboardsurfer.android.widget.crouton.Crouton;
-import de.keyboardsurfer.android.widget.crouton.Style;
+
public class NewsFragment extends SwipeRefreshRecyclerViewFragment
implements SwipeRefreshLayout.OnRefreshListener {
@@ -149,8 +150,9 @@ public void onGet(Object item) {
ActivityFeed feed = (ActivityFeed) item;
if (isAdded()) {
- Crouton.makeText(getActivity(), R.string.cached_content,
- Style.INFO, R.id.content_frame).show();
+ Snackbar snackbar = Snackbar.make(getView(), R.string.cached_content,
+ Snackbar.LENGTH_SHORT);
+ ColoredSnackBar.alert(snackbar).show();
}
mAdapter.addAll(feed.getItems());
@@ -160,8 +162,9 @@ public void onGet(Object item) {
@Override
public void onNotFound(String key) {
if (isAdded()) {
- Crouton.makeText(getActivity(), R.string.offline_alert,
- Style.ALERT, R.id.content_frame).show();
+ Snackbar snackbar = Snackbar.make(getView(), R.string.offline_alert,
+ Snackbar.LENGTH_SHORT);
+ ColoredSnackBar.alert(snackbar).show();
}
}
});
@@ -30,17 +30,13 @@
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.games.Games;
import com.google.android.gms.plus.Plus;
-
import org.gdg.frisbee.android.R;
import org.gdg.frisbee.android.achievements.AchievementActionHandler;
import org.gdg.frisbee.android.utils.PrefUtils;
import org.gdg.frisbee.android.utils.ScopedBus;
import org.gdg.frisbee.android.utils.Utils;
-
import java.util.List;
-
import butterknife.ButterKnife;
-import de.keyboardsurfer.android.widget.crouton.Crouton;
public abstract class GdgActivity extends TrackableActivity implements
GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
@@ -233,7 +229,6 @@ private void resolveSignInError() {
@Override
public void onDestroy() {
super.onDestroy();
- Crouton.cancelAllCroutons();
}
@Override
@@ -22,6 +22,7 @@
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
+import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.widget.ShareActionProvider;
@@ -54,13 +55,12 @@
import org.gdg.frisbee.android.app.App;
import org.gdg.frisbee.android.cache.ModelCache;
import org.gdg.frisbee.android.utils.Utils;
+import org.gdg.frisbee.android.view.ColoredSnackBar;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import butterknife.ButterKnife;
import butterknife.InjectView;
-import de.keyboardsurfer.android.widget.crouton.Crouton;
-import de.keyboardsurfer.android.widget.crouton.Style;
import retrofit.Callback;
import retrofit.RetrofitError;
import timber.log.Timber;
@@ -117,8 +117,9 @@ public void success(EventFullDetails eventFullDetails, retrofit.client.Response
@Override
public void failure(RetrofitError error) {
if (isAdded()) {
- Crouton.makeText(getActivity(), R.string.server_error,
- Style.ALERT, R.id.content_frame).show();
+ Snackbar snackbar = Snackbar.make(getView(), R.string.server_error,
+ Snackbar.LENGTH_SHORT);
+ ColoredSnackBar.alert(snackbar).show();
}
Timber.d(error, "error while retrieving event %s", eventId);
}
@@ -179,15 +180,17 @@ public void success(Directory directory, retrofit.client.Response response) {
@Override
public void failure(RetrofitError error) {
if (isAdded()) {
- Crouton.makeText(getActivity(), R.string.fetch_chapters_failed,
- Style.ALERT, R.id.content_frame).show();
+ Snackbar snackbar = Snackbar.make(getView(), R.string.fetch_chapters_failed,
+ Snackbar.LENGTH_SHORT);
+ ColoredSnackBar.alert(snackbar).show();
}
Timber.e(error, "Could'nt fetch chapter list");
}
});
} else {
- Crouton.makeText(getActivity(), R.string.offline_alert,
- Style.ALERT, R.id.content_frame).show();
+ Snackbar snackbar = Snackbar.make(getView(), R.string.offline_alert,
+ Snackbar.LENGTH_SHORT);
+ ColoredSnackBar.alert(snackbar).show();
}
}
});
@@ -19,6 +19,7 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
+import android.support.design.widget.Snackbar;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.MenuItem;
@@ -32,14 +33,12 @@
import org.gdg.frisbee.android.api.model.SimpleEvent;
import org.gdg.frisbee.android.event.EventActivity;
import org.gdg.frisbee.android.common.GdgListFragment;
+import org.gdg.frisbee.android.view.ColoredSnackBar;
import org.joda.time.DateTime;
import org.joda.time.MutableDateTime;
-
import java.util.ArrayList;
-
import butterknife.ButterKnife;
-import de.keyboardsurfer.android.widget.crouton.Crouton;
-import de.keyboardsurfer.android.widget.crouton.Style;
+
/**
* GDG Aachen
@@ -60,8 +59,9 @@ protected void onError(Throwable e) {
setIsLoading(false);
e.printStackTrace();
if (isAdded()) {
- Crouton.makeText(getActivity(), R.string.fetch_events_failed,
- Style.ALERT, R.id.content_frame).show();
+ Snackbar snackbar = Snackbar.make(getView(), R.string.fetch_events_failed,
+ Snackbar.LENGTH_SHORT);
+ ColoredSnackBar.alert(snackbar).show();
}
}
@@ -1,19 +1,17 @@
package org.gdg.frisbee.android.eventseries;
import android.os.Bundle;
+import android.support.design.widget.Snackbar;
import org.gdg.frisbee.android.Const;
import org.gdg.frisbee.android.R;
import org.gdg.frisbee.android.api.model.Event;
import org.gdg.frisbee.android.app.App;
import org.gdg.frisbee.android.cache.ModelCache;
import org.gdg.frisbee.android.utils.Utils;
+import org.gdg.frisbee.android.view.ColoredSnackBar;
import org.joda.time.DateTime;
-
import java.util.ArrayList;
-
-import de.keyboardsurfer.android.widget.crouton.Crouton;
-import de.keyboardsurfer.android.widget.crouton.Style;
import retrofit.Callback;
import retrofit.RetrofitError;
@@ -71,15 +69,17 @@ public void onGet(Object item) {
mAdapter.addAll(events);
setIsLoading(false);
- Crouton.makeText(getActivity(), R.string.cached_content,
- Style.INFO, R.id.content_frame).show();
+ Snackbar snackbar = Snackbar.make(getView(), R.string.cached_content,
+ Snackbar.LENGTH_SHORT);
+ ColoredSnackBar.info(snackbar).show();
}
@Override
public void onNotFound(String key) {
setIsLoading(false);
- Crouton.makeText(getActivity(), R.string.offline_alert,
- Style.ALERT, R.id.content_frame).show();
+ Snackbar snackbar = Snackbar.make(getView(), R.string.offline_alert,
+ Snackbar.LENGTH_SHORT);
+ ColoredSnackBar.alert(snackbar).show();
}
});
}
Oops, something went wrong.

6 comments on commit f439412

@friedger
Member

@PareshMayani Nice contributions!

It would be nice if you could send a pull request with your changes and then someone else can review it. It gives a better flow for the project and bundles commits nicely.
Not sure whether this is stated anywhere but we try to

  • not push to develop/master
  • not merge your own pull requests

Keep the contributions coming :-)

@tasomaniac
Member

@PareshMayani I actually removed the direct pushes to the develop branch. Can you create a new branch and open a pull request with these great changes. Thank you.

@PareshMayani
Member

@friedger Yes I just followed the same steps which I was following before Push rights are assigned to me. Like creating a separate branch and committing my code into it and then sending a pull request.

But my mistake I didn't selected origin and it was "gdg-x" selected by default in Android studio.

Will make sure I will check the proper repository and branch selected next time onwards.

@PareshMayani
Member

@tasomaniac no problem :) I enjoyed weekend by integrating design support library but the sad thing is I can't see my weekend enjoyment into the action :P no worries, will integrate those changes again and will send a pull request separately!

@PareshMayani
Member

Here is what I said in above comments :)

check

@tasomaniac
Member

Nice 😄 I see the Pull Request now and will have a look at it as soon as possible.

Please sign in to comment.