Skip to content

loopeer/ProjectDevelopModule

Repository files navigation

ProjectDevelopModule

Catalog

CompatInset

=== One fasion in the library to solve make status bar transparent.Idea from CoordinatorLayout and CollapsingToolbarLayout.

Installation

dependencies {
    compile 'com.loopeer.library:compatinset:0.0.5-beta36'
}
Api16 Api19 Api23
Full transparency status bar Full transparency status bar
Full transparency status bar
singleholder With translucent status bar in native system same to top same to top
singleholder With translucent status bar in native system same to top same to top

Usages

Singleholder With translucent status bar in native system
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <com.loopeer.compatinset.SingleInsetHolderView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:insetStatusBarColor="@android:color/transparent"/>

    <ImageView
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/inset_holder"
        android:layout_gravity="right"
        android:layout_margin="10dp"
        android:src="@android:drawable/ic_dialog_email"/>
</LinearLayout>

If you want support edittext softinput pop to push layout top. You should add android:windowSoftInputMode="adjustResize". Add for the EditText parent such as Relative,Frame,Coord Layout app:softCompat="true". For the LinearLayout,add that in the linearlayout's parent ScrollView

<activity
    android:name=".CompatSingleInsetToolbarActivity"
    android:theme="@style/AppTheme.SingleNoActionBar"
    android:windowSoftInputMode="adjustResize">
    <meta-data
        android:name="android.support.PARENT_ACTIVITY"
        android:value=".MainActivity"/>
</activity>
Full transparency status bar

The parents wrap InsetHolderView must be support the inset just as InsetLinearLayout in library.You can new create use the InsetHelper.

<com.loopeer.compatinset.InsetLinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <com.loopeer.compatinset.InsetHolderView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:insetStatusBarColor="@android:color/transparent"/>

    <ImageView
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/inset_holder"
        android:layout_gravity="right"
        android:layout_margin="10dp"
        android:src="@android:drawable/ic_dialog_email"/>
</com.loopeer.compatinset.InsetLinearLayout>

Then set up AppTheme.NoActionBar theme values-v19:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowTranslucentStatus">true</item>
    </style>
</resources>

values-v21:

<resources>
    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
    </style>
</resources>

BottomDialog

===

Screenshot

Installation

dependencies {
    compile 'com.loopeer.library:bottomdialog:0.0.5-beta36'
}

Usages

new BottomDateTimeDialog.Builder(this)
        .updateDateTime(Calendar.getInstance().getTimeInMillis())
        .setDateSelectListener(
                new BottomDateTimeDialog.OnDateSelectListener() {
                    @Override
                    public void onDateSelected(Calendar calendar) {
                        updateDateTimeText(calendar);
                    }
                })
        .setDateTimeMode(mDateTimeMode)
        .show();

AddressPicker

===

Screenshot

Installation

dependencies {
    compile 'com.loopeer.library:addresspicker:0.0.5-beta36'
}

Usages

new AddressPickerDialog.Builder(this)
            .setTitle(title)
            //bottom or alert dialog
            .setDialogType(mType)
            //show province | city | district
            .setAddressMode(mMode)
            //if you want to show the last address you have picked,just record the params and set them
            .setProvinceIndex(provinceIndex)
            .setCityIndex(cityIndex)
            .setDistrictIndex(districtIndex)
            .setOnPickerListener(new OnAddressPickListener() {
                @Override public void onConfirm(AddressPickerView pickerView) {
                    mTextAddress.setText(getString(
                        R.string.address_format,pickerView.getProvince(), pickerView.getCity(),
                        pickerView.getDistrict()));
                    //record params
                    provinceIndex = pickerView.getProvinceIndex();
                    cityIndex = pickerView.getCityIndex();
                    districtIndex = pickerView.getDistrictIndex();
                }


                @Override public void onCancel() {

                }
            })
            .show();

DevelopUtil

===

Installation

dependencies {
    compile 'com.loopeer.library:developutil:0.0.5-beta36'
}

Usages

ClickSpanHelper

new ClickSpanHelper.Builder(mBinding.textTestClickSpan
        , R.string.contentString)
        .setHighlightColor(0)
        .setColor(R.color.colorAccent)
        .setSpanUnderLine(false)
        .setSpanBold(false)
        .addClickSpanParam(R.string.first_click_string, widget -> method1())
        .addClickSpanParam(R.string.second_click_string, widget -> method2())
        .addClickSpanParam(R.string.third_click_string, new ClickableSpan() {
            @Override
            public void onClick(View widget) {
                method3();
            }

            @Override
            public void updateDrawState(TextPaint ds) {
                ds.setUnderlineText(true);
                ds.setColor(ContextCompat.getColor(BaseDevelopUtilsActivity.this, R.color.colorPrimary));
            }
        }).build();
DoubleClickHelper

Add Double click event for view with single click.

new DoubleClickHelper.Builder(targetView)
        .setDoubleClickListener(e -> doubleClickEvent())
        .setSingleClickListener(event -> singleClickEvent())
        .build();
BankNoSpaceWatcher

One TextWatcher to format the bank card no to add space auto.

new BankNoSpaceWatcher().apply(edittext);
CaptchaHelper

Wraping CountDownTimer and TextView to let add captcha easy.

mCaptchaHelper = new CaptchaHelper.Builder(mBinding.textPhoneCaptcha)
        .setTimeFuture(10)
        .build();

mBinding.textPhoneCaptcha.setOnClickListener(v -> {
    mCaptchaHelper.start();// assume the this is one request callback.Then to start count down
});

Builder method:

  • setSendText(has default)
  • setTimeRemainText(string res with one integer param,has default)
  • setTimeFuture(seconds default 60)

When go out of activity(onDestroy) or fragment(onDestroyView) you should cancel the CountDownTimer.

mCaptchaHelper.cancel();

ImageSwitcher

===

dependencies {
    compile 'com.loopeer.library:imageswitcher:0.0.5-beta36'
}

Usages

NavigatorImage.startImageSwitchActivity(this,  Arrays.asList(sImages), 3, R.mipmap.ic_image_default);

AppUpdate

=== Apk Update helper with apk version check and download apk service.

dependencies {
    compile 'com.loopeer.library:appupdate:0.0.5-beta36'
}

Usages

AppUpdate.apply(this
    , title
    , description
    , url
    , getString(R.string.app_name)
    , R.drawable.ic_launcher);

SpringViewGroup

===

Usages

SpringRecyclerView SpringScrollView

Databindpack and FormItemView

===

Databindpack

Databindpack provide a fast way to build large form,which is inspired by the two-way binding.
Feature:
1.since the ui and data are bind in two-way. there is no need to use setXXX and getXXX Method of TextView.And also the TextWatcher is no need to set.
2.a easy way to check whether the data is modified.

FormItemView

FormItemView contains two easy custom view —— FormEditItem / FormTextItem to help us build form more efficiently. both view provide databinding adpater.
for more detail,please see the FormValidatorActivity and FormItemViewActivity.