Skip to content
This repository has been archived by the owner on Jun 5, 2018. It is now read-only.

Commit

Permalink
Fallback mode for #798
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Shatunov committed Mar 2, 2014
1 parent 6e21772 commit 4e4671c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions library/src/org/holoeverywhere/widget/Toast.java
Expand Up @@ -2,10 +2,13 @@
package org.holoeverywhere.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.view.View;

import org.holoeverywhere.LayoutInflater;
import org.holoeverywhere.R;
import org.holoeverywhere.ThemeManager;
import org.holoeverywhere.app.ContextThemeWrapperPlus;

public class Toast extends android.widget.Toast {
public static final int LENGTH_LONG = android.widget.Toast.LENGTH_LONG;
Expand All @@ -16,6 +19,13 @@ public Toast(Context context) {
}

public static Toast makeText(Context context, CharSequence s, int duration) {
// Fallback mode
TypedArray a = context.obtainStyledAttributes(new int[]{R.attr.holoTheme});
if (a.getInt(0, ThemeManager.INVALID) == ThemeManager.INVALID) {
context = new ContextThemeWrapperPlus(context, ThemeManager.getThemeResource(ThemeManager.getDefaultTheme()));
}
a.recycle();

final View view = LayoutInflater.inflate(context, R.layout.transient_notification);
((TextView) view.findViewById(android.R.id.message)).setText(s);

Expand Down

0 comments on commit 4e4671c

Please sign in to comment.