This commit is contained in:
wangcongtao
2020-05-29 09:50:27 +08:00
parent ff769c325e
commit 80ac1ed05e
14 changed files with 262 additions and 240 deletions

View File

@@ -70,33 +70,15 @@ public class AbsMogoApplication extends Application {
ARouter.openLog();
}
ARouter.init( sApp );
TipToast.init( this, new TipToast.ToastViewGenerator() {
@Override
public View make( Context context, String message ) {
if ( TextUtils.isEmpty( message ) ) {
return null;
}
View contentView = LayoutInflater.from( context ).inflate( R.layout.module_commons_layout_toast, null );
TextView txt = contentView.findViewById( R.id.module_commons_toast_msg );
txt.setText( message );
return contentView;
TipToast.init( this, ( ( context, message ) -> {
if ( TextUtils.isEmpty( message ) ) {
return null;
}
@Override
public int gravity() {
return Gravity.TOP | Gravity.CENTER_HORIZONTAL;
}
@Override
public int yOffset() {
return sApp.getResources().getDimensionPixelSize( R.dimen.module_commons_toast_y_offset );
}
@Override
public int xOffset() {
return 0;
}
} );
View contentView = LayoutInflater.from( context ).inflate( R.layout.module_commons_layout_toast, null );
TextView txt = contentView.findViewById( R.id.module_commons_toast_msg );
txt.setText( message );
return contentView;
} ) );
}
/**

View File

@@ -20,6 +20,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {

View File

@@ -170,11 +170,17 @@ public final class TipToast {
public interface ToastViewGenerator {
View make( Context context, String message );
int gravity();
default int gravity() {
return Gravity.CENTER;
}
int yOffset();
default int yOffset() {
return 0;
}
int xOffset();
default int xOffset() {
return 0;
}
}
}