-
Notifications
You must be signed in to change notification settings - Fork 3
Feature List
aryx edited this page Jul 26, 2021
·
31 revisions
Coconut 2.3.0-rc.8
1. Use CoconutAlertNoConnectionDialog , handle for if no connection and retry
Just override layout
R.layout.dialog_coconut_alert_no_connection
. In xml layout , existinct component can be override on your app :
- coconut_image (ImageView)
- coconut_message (TextView)
- coconut_full_message (TextView)
- coconut_btn_reconnect (Button)
<!-- dialog_coconut_alert_no_connection.xml, please override layout below as custom layout you expect -->
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/color_white">
<ImageView
android:id="@+id/coconut_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_above="@+id/coconut_message"
android:src="@drawable/no_wifi_image" />
<TextView
android:id="@+id/coconut_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="22dp"
android:layout_centerInParent="true"
android:text="@string/coconut_internet_fail_message"
android:textColor="@color/color_black"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/coconut_full_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/coconut_message"
android:layout_centerHorizontal="true"
android:layout_marginHorizontal="30dp"
android:layout_marginTop="8dp"
android:gravity="center_horizontal"
android:text="@string/coconut_internet_fail_full_message"
android:textAlignment="center"
android:textColor="@color/color_black"
android:textSize="14sp" />
<!-- The button action will retry behaviour from your current activity in any section in your App -->
<Button
android:id="@+id/coconut_btn_reconnect"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_below="@+id/coconut_full_message"
android:layout_centerHorizontal="true"
android:layout_marginTop="24dp"
android:background="@drawable/rounded_button_blue"
android:drawablePadding="5dp"
android:padding="20dp"
android:text="@string/btn_reconnection_text"
android:textAllCaps="false"
android:textColor="@color/color_white" />
</RelativeLayout>
2. Using custom font
-
Put your font assets files under
res/font
-
Setup default font:
[styles.xml] <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Customize your theme here. --> ... <item name="android:fontFamily">@font/custom_font</item> </style> <style name="YourCustomFontType" parent="android:TextAppearance"> <item name="android:fontFamily">@font/another_custom_font</item> </style>
-
In TextView:
<TextView ... android:textAppearance="@style/YourCustomFontType" />
3. Custom timeout HTTP Request
// Api.java
(ApiService) getInstance()
.setupApi(App.getAppComponent(), ApiService.class, true,
app.beelabs.com.codebase.IConfig.TIMEOUT_SHORT_INSECOND,
BuildConfig.IS_DEBUG);
4. Color resources loading dialog layout
styles.xml
// custom style color background , update color hex in color.xml
<color name="colorCoconut_background_dialog">#CCFFFFFF</color>
<color name="colorCoconut_text_dialog">#fff</color>
<color name="colorCoconut_iconloading_dialog">#ababab</color>
5. Use Api Loading Dialog
////// [UI]
new ResourcePresenter(this).getSourceRX("Ambil Data", RxObserver.DialogTypeEnum.SPINKIT);
////// [Presenter]
// RxObserver use specific type of view layout
// 1. DEFAULT
// 2. SPINKIT
// write in Presenter layer
new ResourceDao(this).getSourceRXDAO()
.subscribe(new RxObserver<ProfileResponseModel>(imv, messageLoading) { ... }
.setDialogType(RxObserver.DialogTypeEnum.SPINKIT)
You can override this layout by use resource id
R.layout.dialog_coconut_spinkit_loading.xml
[Layout Default]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<app.beelabs.com.codebase.component.spinkit.CoconutSpinKitView
style="@style/SpinKitView.WanderingCubes"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_centerHorizontal="true" />
<TextView
android:id="@+id/coconut_spinkit_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:text="Loading..."
android:textColor="@color/colorCoconut_text_dialog" />
</LinearLayout>
</LinearLayout>
6. Support fragment back stack while back button pressed
showFragment(<OBJECT_OF_FRAGMENT,
<RESOURCE_ID_FOR_PUT_FRAGMENT_IN_PARENT_VIEW>,
<IS_USE_FRAGMENT_BACKSTACK> );
7. Implementation RxTimer
RxTimer.doTimer(long delay, boolean repeat, RxTimer callback)
8. Prevent from being Rooted, FakeGPS, shareApp
SecurityUtil.isPackageInstalled(new String[]{"com.xxxx.app"}, getPackageManager());
SecurityUtil.isRooted();
SecurityUtil.isMockLocationEnabled(this);
9. Support custom OkHTTPClient interceptor
synchronized private static ApiService initApiDomain() {
return (ApiService) getInstance()
.setupApiDomain(IConfig.API_BASE_URL, App.getAppComponent(),
ApiService.class,
true,
app.beelabs.com.codebase.IConfig.TIMEOUT_SHORT_INSECOND, BuildConfig.IS_DEBUG,
new Interceptor[]{ new RSAInterceptor()}, // interceptor preload
new Interceptor[]{ new RSAInterceptor()} // network interceptor postload
);
}