21
21
import android .content .res .Resources ;
22
22
import android .view .LayoutInflater ;
23
23
import android .view .View ;
24
+ import android .view .View .OnClickListener ;
24
25
import android .view .ViewGroup ;
25
26
import android .view .ViewGroup .LayoutParams ;
26
27
import android .view .animation .Animation ;
@@ -132,8 +133,21 @@ public static AppMsg makeText(Activity context, CharSequence text, Style style)
132
133
return makeText (context , text , style , R .layout .app_msg );
133
134
}
134
135
136
+
137
+ /**
138
+ * Make a {@link AppMsg} that just contains a text view.
139
+ *
140
+ * @param context The context to use. Usually your
141
+ * {@link android.app.Activity} object.
142
+ * @param text The text to show. Can be formatted text.
143
+ * @param style The style with a background and a duration.
144
+ */
145
+ public static AppMsg makeText (Activity context , CharSequence text , Style style , OnClickListener clickListener ) {
146
+ return makeText (context , text , style , R .layout .app_msg );
147
+ }
148
+
135
149
/**
136
- * @author mengguoqiang 扩展支持设置字体大小
150
+ * @author mengguoqiang
137
151
* Make a {@link AppMsg} that just contains a text view.
138
152
*
139
153
* @param context The context to use. Usually your
@@ -144,6 +158,20 @@ public static AppMsg makeText(Activity context, CharSequence text, Style style)
144
158
public static AppMsg makeText (Activity context , CharSequence text , Style style , float textSize ) {
145
159
return makeText (context , text , style , R .layout .app_msg , textSize );
146
160
}
161
+
162
+
163
+ /**
164
+ * @author mengguoqiang
165
+ * Make a {@link AppMsg} that just contains a text view.
166
+ *
167
+ * @param context The context to use. Usually your
168
+ * {@link android.app.Activity} object.
169
+ * @param text The text to show. Can be formatted text.
170
+ * @param style The style with a background and a duration.
171
+ */
172
+ public static AppMsg makeText (Activity context , CharSequence text , Style style , float textSize , OnClickListener clickListener ) {
173
+ return makeText (context , text , style , R .layout .app_msg , textSize , clickListener );
174
+ }
147
175
148
176
/**
149
177
* Make a {@link AppMsg} with a custom layout. The layout must have a {@link TextView} com id {@link android.R.id.message}
@@ -161,8 +189,44 @@ public static AppMsg makeText(Activity context, CharSequence text, Style style,
161
189
return makeText (context , text , style , v , true );
162
190
}
163
191
192
+
164
193
/**
165
- * @author mengguoqiang 扩展支持字体大小
194
+ * Make a {@link AppMsg} with a custom layout. The layout must have a {@link TextView} com id {@link android.R.id.message}
195
+ *
196
+ * @param context The context to use. Usually your
197
+ * {@link android.app.Activity} object.
198
+ * @param text The text to show. Can be formatted text.
199
+ * @param style The style with a background and a duration.
200
+ */
201
+ public static AppMsg makeText (Activity context , CharSequence text , Style style , int layoutId , OnClickListener clickListener ) {
202
+ LayoutInflater inflate = (LayoutInflater )
203
+ context .getSystemService (Context .LAYOUT_INFLATER_SERVICE );
204
+ View v = inflate .inflate (layoutId , null );
205
+
206
+ return makeText (context , text , style , v , true );
207
+ }
208
+
209
+
210
+
211
+ /**
212
+ * @author mengguoqiang
213
+ * Make a {@link AppMsg} with a custom layout. The layout must have a {@link TextView} com id {@link android.R.id.message}
214
+ *
215
+ * @param context The context to use. Usually your
216
+ * {@link android.app.Activity} object.
217
+ * @param text The text to show. Can be formatted text.
218
+ * @param style The style with a background and a duration.
219
+ */
220
+ public static AppMsg makeText (Activity context , CharSequence text , Style style , int layoutId , float textSize , OnClickListener clickListener ) {
221
+ LayoutInflater inflate = (LayoutInflater )
222
+ context .getSystemService (Context .LAYOUT_INFLATER_SERVICE );
223
+ View v = inflate .inflate (layoutId , null );
224
+
225
+ return makeText (context , text , style , v , true , textSize , clickListener );
226
+ }
227
+
228
+ /**
229
+ * @author mengguoqiang
166
230
* Make a {@link AppMsg} with a custom layout. The layout must have a {@link TextView} com id {@link android.R.id.message}
167
231
*
168
232
* @param context The context to use. Usually your
@@ -177,6 +241,9 @@ public static AppMsg makeText(Activity context, CharSequence text, Style style,
177
241
178
242
return makeText (context , text , style , v , true , textSize );
179
243
}
244
+
245
+
246
+
180
247
181
248
/**
182
249
* Make a non-floating {@link AppMsg} with a custom view presented inside the layout.
@@ -192,6 +259,24 @@ public static AppMsg makeText(Activity context, CharSequence text, Style style,
192
259
public static AppMsg makeText (Activity context , CharSequence text , Style style , View customView ) {
193
260
return makeText (context , text , style , customView , false );
194
261
}
262
+
263
+
264
+
265
+ /**
266
+ * Make a non-floating {@link AppMsg} with a custom view presented inside the layout.
267
+ * It can be used to create non-floating notifications if floating is false.
268
+ *
269
+ * @param context The context to use. Usually your
270
+ * {@link android.app.Activity} object.
271
+ * @param customView
272
+ * View to be used.
273
+ * @param text The text to show. Can be formatted text.
274
+ * @param style The style with a background and a duration.
275
+ */
276
+ public static AppMsg makeText (Activity context , CharSequence text , Style style , View customView , OnClickListener clickListener ) {
277
+ return makeText (context , text , style , customView , false , clickListener );
278
+ }
279
+
195
280
196
281
/**
197
282
* Make a {@link AppMsg} with a custom view. It can be used to create non-floating notifications if floating is false.
@@ -208,9 +293,26 @@ private static AppMsg makeText(Activity context, CharSequence text, Style style,
208
293
return makeText (context , text , style , view , floating , 0 );
209
294
}
210
295
296
+
297
+
298
+ /**
299
+ * Make a {@link AppMsg} with a custom view. It can be used to create non-floating notifications if floating is false.
300
+ *
301
+ * @param context The context to use. Usually your
302
+ * {@link android.app.Activity} object.
303
+ * @param view
304
+ * View to be used.
305
+ * @param text The text to show. Can be formatted text.
306
+ * @param style The style with a background and a duration.
307
+ * @param floating true if it'll float.
308
+ */
309
+ private static AppMsg makeText (Activity context , CharSequence text , Style style , View view , boolean floating , OnClickListener clickListener ) {
310
+ return makeText (context , text , style , view , floating , 0 , clickListener );
311
+ }
312
+
211
313
/**
212
314
*
213
- * @author mengguoqiang 扩展支持设置字体大小
315
+ * @author mengguoqiang
214
316
* Make a {@link AppMsg} with a custom view. It can be used to create non-floating notifications if floating is false.
215
317
*
216
318
* @param context The context to use. Usually your
@@ -236,6 +338,47 @@ private static AppMsg makeText(Activity context, CharSequence text, Style style,
236
338
237
339
return result ;
238
340
}
341
+
342
+
343
+
344
+ /**
345
+ *
346
+
347
+ * Make a {@link AppMsg} with a custom view. It can be used to create non-floating notifications if floating is false.
348
+ *
349
+ * @param context The context to use. Usually your
350
+ * {@link android.app.Activity} object.
351
+ * @param view
352
+ * View to be used.
353
+ * @param text The text to show. Can be formatted text.
354
+ * @param style The style with a background and a duration.
355
+ * @param floating true if it'll float.
356
+ * @param clickListener Clicklistener
357
+ */
358
+ private static AppMsg makeText (Activity context , CharSequence text , Style style , View view , boolean floating ,
359
+ float textSize , OnClickListener clickListener ) {
360
+ AppMsg result = new AppMsg (context );
361
+
362
+ view .setBackgroundResource (style .background );
363
+ view .setClickable (true );
364
+
365
+ TextView tv = (TextView ) view .findViewById (android .R .id .message );
366
+ if (textSize > 0 ) tv .setTextSize (textSize );
367
+ tv .setText (text );
368
+
369
+ result .mView = view ;
370
+ result .mDuration = style .duration ;
371
+ result .mFloating = floating ;
372
+
373
+ view .setOnClickListener (clickListener );
374
+
375
+ return result ;
376
+ }
377
+
378
+
379
+
380
+
381
+
239
382
240
383
/**
241
384
* Make a {@link AppMsg} with a custom view. It can be used to create non-floating notifications if floating is false.
0 commit comments