Skip to content

Commit b87b10d

Browse files
author
mobyiapps
committed
Update
1 parent 41c8369 commit b87b10d

File tree

7 files changed

+57
-9
lines changed

7 files changed

+57
-9
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ android {
44
compileSdkVersion 28
55
defaultConfig {
66
applicationId "com.dvinfosys.WidgetsExample"
7-
minSdkVersion 15
7+
minSdkVersion 16
88
targetSdkVersion 28
99
versionCode 1
1010
versionName "1.0"

app/src/main/java/com/dvinfosys/WidgetsExample/MainActivity.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
package com.dvinfosys.WidgetsExample;
22

33
import android.content.Context;
4+
import android.graphics.Typeface;
5+
import android.graphics.drawable.Drawable;
46
import android.net.Uri;
57
import android.os.Bundle;
68
import android.support.v7.app.AppCompatActivity;
9+
import android.text.Spannable;
10+
import android.text.SpannableStringBuilder;
11+
import android.text.style.StyleSpan;
712
import android.view.View;
813
import android.widget.Button;
914

1015
import com.dvinfosys.widgets.ToastView.ToastView;
1116
import com.dvinfosys.widgets.VideoPlayer.VPVideoPlayer;
1217
import com.dvinfosys.widgets.VideoPlayer.VPVideoPlayerStandard;
1318

19+
import static android.graphics.Typeface.BOLD_ITALIC;
20+
1421
public class MainActivity extends AppCompatActivity {
1522

1623
private Context context;
@@ -55,6 +62,49 @@ public void onClick(View v) {
5562
ToastView.success(context,"This is success ToastView",ToastView.LENGTH_SHORT).show();
5663
}
5764
});
65+
66+
findViewById(R.id.button_normal_toast_wo_icon).setOnClickListener(new View.OnClickListener() {
67+
@Override
68+
public void onClick(View view) {
69+
ToastView.normal(MainActivity.this, "normal message without icon").show();
70+
}
71+
});
72+
findViewById(R.id.button_normal_toast_w_icon).setOnClickListener(new View.OnClickListener() {
73+
@Override
74+
public void onClick(View view) {
75+
Drawable icon = getResources().getDrawable(R.drawable.menu);
76+
ToastView.normal(MainActivity.this, "normal message with icon", icon).show();
77+
}
78+
});
79+
findViewById(R.id.button_info_toast_with_formatting).setOnClickListener(new View.OnClickListener() {
80+
@Override
81+
public void onClick(View view) {
82+
ToastView.info(MainActivity.this, getFormattedMessage()).show();
83+
}
84+
});
85+
findViewById(R.id.button_custom_config).setOnClickListener(new View.OnClickListener() {
86+
@Override
87+
public void onClick(View view) {
88+
ToastView.Config.getInstance()
89+
.setToastTypeface(Typeface.createFromAsset(getAssets(), "fonts/Smoothy.otf"))
90+
.allowQueue(false)
91+
.apply();
92+
ToastView.custom(MainActivity.this, R.string.custom_message, getResources().getDrawable(R.drawable.menu),
93+
android.R.color.black, android.R.color.holo_green_light, ToastView.LENGTH_SHORT, true, true).show();
94+
ToastView.Config.reset(); // Use this if you want to use the configuration above only once
95+
}
96+
});
97+
}
98+
99+
private CharSequence getFormattedMessage() {
100+
final String prefix = "Formatted ";
101+
final String highlight = "bold italic";
102+
final String suffix = " text";
103+
SpannableStringBuilder ssb = new SpannableStringBuilder(prefix).append(highlight).append(suffix);
104+
int prefixLen = prefix.length();
105+
ssb.setSpan(new StyleSpan(BOLD_ITALIC),
106+
prefixLen, prefixLen + highlight.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
107+
return ssb;
58108
}
59109

60110
@Override

app/src/main/res/drawable/menu.png

9.16 KB
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<resources>
22
<string name="app_name">Widgets</string>
3+
<string name="custom_message">Custom Message ToastView</string>
34
</resources>

libraries/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ android {
55

66

77
defaultConfig {
8-
minSdkVersion 15
8+
minSdkVersion 16
99
targetSdkVersion 28
1010
versionCode 1
1111
versionName "1.0"
@@ -25,7 +25,7 @@ android {
2525

2626
dependencies {
2727
implementation fileTree(dir: 'libs', include: ['*.jar'])
28-
28+
implementation 'com.intuit.sdp:sdp-android:1.0.6'
2929
implementation 'com.android.support:appcompat-v7:28.0.0'
3030
testImplementation 'junit:junit:4.12'
3131
androidTestImplementation 'com.android.support.test:runner:1.0.2'

libraries/src/main/java/com/dvinfosys/widgets/ToastView/ToastView.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ public static Toast custom(@NonNull Context context, @NonNull CharSequence messa
310310
lastToast.cancel();
311311
lastToast = currentToast;
312312
}
313-
314313
return currentToast;
315314
}
316315

@@ -331,7 +330,7 @@ public static Config getInstance() {
331330

332331
public static void reset() {
333332
ToastView.currentTypeface = LOADED_TOAST_TYPEFACE;
334-
ToastView.textSize = 16;
333+
ToastView.textSize = 12;
335334
ToastView.tintIcon = true;
336335
ToastView.allowQueue = true;
337336
}

libraries/src/main/res/layout/toast_view_layout.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111

1212
<ImageView
1313
android:id="@+id/toast_icon"
14-
android:layout_width="24dp"
15-
android:layout_height="24dp"
16-
android:layout_marginEnd="8dp"
17-
android:layout_marginRight="8dp"
14+
android:layout_width="@dimen/_20sdp"
15+
android:layout_height="@dimen/_20sdp"
1816
android:contentDescription="@string/toast_message" />
1917

2018
<com.dvinfosys.widgets.TextView.NormalTextView xmlns:android="http://schemas.android.com/apk/res/android"

0 commit comments

Comments
 (0)