An open API service indexing awesome lists of open source software.

https://github.com/boybeak/starter

A quick starter package for android developer.
https://github.com/boybeak/starter

drag-exit imagepicker permission-android starter

Last synced: about 1 year ago
JSON representation

A quick starter package for android developer.

Awesome Lists containing this project

README

          

# Starter

中文[Readme.md](https://github.com/boybeak/Starter/blob/master/README_cn.md)

There are 4 libraries in this project:[ **Starter**](https://github.com/boybeak/Starter#starter--), [**Drag-Exit**](https://github.com/boybeak/Starter#drag-exit--), [**Permission**](https://github.com/boybeak/Starter#permission--), [**Picker**](https://github.com/boybeak/Starter#picker--), [**SAFR**](https://github.com/boybeak/Starter#safr--)

## Starter[ ![Starter](https://api.bintray.com/packages/boybeak/nulldreams/starter/images/download.svg) ](https://bintray.com/boybeak/nulldreams/starter/_latestVersion)

This is a quick start package, including BaseActivity, BaseFragment and utils classes;

```groovy
implementation 'com.github.boybeak:starter:x.y.z'
```

#### Starter structure

| package | class | description |
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| [**activity**](https://github.com/boybeak/Starter/wiki/activity) | [BaseActivity](https://github.com/boybeak/Starter/wiki/activity#baseactivity),[BaseDragExitActivity](https://github.com/boybeak/Starter/wiki/activity#basedragexitactivity),[DataBindingActivity](https://github.com/boybeak/Starter/wiki/activity#basedragexitactivity),DataBindingToolbarActivity,DragExitToolbarActivity, SrlRvActivity, [ToolbarActivity](https://github.com/boybeak/Starter/wiki/activity#toolbaractivity),ToolbarViewPagerActivity | Some basic activities |
| [**adapter**](https://github.com/boybeak/Starter/wiki/adapter) | [DataBindingAdapter](https://github.com/boybeak/Starter/wiki/adapter#databindingadapter),[FooterAdapter](https://github.com/boybeak/Starter/wiki/adapter#footeradapter),BaseLayoutImpl,AbsDataBindingHolder, [DataChange](https://github.com/boybeak/Starter/wiki/adapter#datachange) | Only some main class a presented |
| [**broadcast**](https://github.com/boybeak/Starter/wiki/broadcast) | AbsReceiver, BroadcastUtils | Add isRegistered state in AbsReceiver.Use this with **BroadcastUtils** |
| [**fragment**](https://github.com/boybeak/Starter/wiki/fragment) | BaseFragment, BaseDialogFragment, BaseBottomDialogFragment, RefreshListFragment, PaginationFragment | |
| [**mvc**](https://github.com/boybeak/Starter/wiki/mvc) | | It's not too useful |
| [**retrofit**](https://github.com/boybeak/Starter/wiki/retrofit) | SimpleCallback, SimpleListCallback, SafeCallback, SafeListCallback | Some quick retrofit callback |
| [**utils**](https://github.com/boybeak/Starter/wiki/utils) | AssetUtil, Connectivity, FileUtil, ImeUtil | Some useful utils |
| [**widget**](https://github.com/boybeak/Starter/wiki/widget) | BottomHideBehavior, Chip, EmptyView, OnScrollBottomListener, PagerStateAdapter, ProgressBar, RatioCardView, RatioImageView,RatioViewPager, SearchBar, SimpleViewPagerFragmentAdapter | |
| [Others](https://github.com/boybeak/Starter/wiki/Others) | [CrashHandler](https://github.com/boybeak/Starter/wiki/Others/_edit#crashhandler), GetNothingImpl, ILife, [Intents](https://github.com/boybeak/Starter/wiki/Others/_edit#intents), [Memory](https://github.com/boybeak/Starter/wiki/Others/_edit#memory), [Router](https://github.com/boybeak/Starter/wiki/Others/_edit#router), [SafeHandler](https://github.com/boybeak/Starter/wiki/Others/_edit#safehandler) | |

[See full wiki document](https://github.com/boybeak/Starter/wiki)

## Drag-Exit[ ![Download](https://api.bintray.com/packages/boybeak/nulldreams/drag-exit/images/download.svg) ](https://bintray.com/boybeak/nulldreams/drag-exit/_latestVersion)

```groovy
implementation 'com.github.boybeak:drag-exit:x.y.z'
```

![demo gif](https://github.com/boybeak/Starter/blob/master/gif/drag-exit.gif)

There's only one FrameLayout's sub class **DragExitLayout**. Use the layout like this:

```xml


```

```kotlin
class DragExitActivity : AppCompatActivity() {

private val dragListener = object : DragExitLayout.OnExitListener {
override fun onExit() {
finish()
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
super.setContentView(R.layout.activity_drag_exit)

drag_exit_layout.setOnExitListener(dragListener)

web_view.webViewClient = WebViewClient()
web_view.webChromeClient = WebChromeClient()
web_view.loadUrl("https://github.com/boybeak/Starter")
}
}
```

Some attributes as below:

- **activeEdges** - *enum*: 3 values are available, **left**, **right** and **both**, which edge can active the drag gesture.
- **exitLineRatio** - *float*: Available values in range (0, 1), the exit action trigger ratio of layout width.
- **stuckEffect** - *boolean*: Whether should the child view stuck at exitLineRation position or not.
- **lazy** - *float*: Available values in range (0, 1). If set to 0.5, your finger move 100 pixels, the child view actually move 50 pixels.
- **alphaEffect** - *boolean*: Whether the child view change its alpha when moving.
- **alphaMin** - *float*: The minimum value of the child view can be. Once the child view moves to exitLineRation position, the alpha will be alphaMin.
- **scaleEffect** - *boolean*, same as alphaEffect
- **scaleMin** - *float*: same as alphaMin

More about **exitLineRatio** see the image below:

If set exitLineRation to 0.25.

![exitLineRation](https://github.com/boybeak/Starter/blob/master/gif/exitLineRation.png)

> Don't forget use a transparent theme to your activity if you want a drag-exit activity. Or you can use **BaseDragExitActivity** or **DragExitToolbarActivity** in the **Starter** library.

## Permission[ ![Download](https://api.bintray.com/packages/boybeak/nulldreams/permission/images/download.svg) ](https://bintray.com/boybeak/nulldreams/permission/_latestVersion)

This is a permission helper. Quickly grant permissions.

```groovy
implementation 'com.github.boybeak:permission:x.y.z'
```

```kotlin
PH.ask(Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.CAMERA,
Manifest.permission.RECORD_AUDIO).go(this, object : Callback {
override fun onGranted(permissions: MutableList) {
//TODO do what you want
}

override fun onDenied(permission: String) {
//TODO do what you want
}

})
```

**PH** is short for Permission Helper.

## Picker[ ![Picker](https://api.bintray.com/packages/boybeak/nulldreams/picker/images/download.svg) ](https://bintray.com/boybeak/nulldreams/picker/_latestVersion)

A helper library for getting images and videos quickly.

```groovy
implementation 'com.github.boybeak:picker:x.y.z'
```

```kotlin
// Get multiple images from gallery
Picker.gallery().image().multiple(true)
.go(this@PickerActivity, object : MultipleCallback {
override fun onGet(id: String, uris: MutableList, files: MutableList) {
adapter!!.addAll(files, Converter { data, _ -> FileImpl(data) }).autoNotify()
}

override fun onCancel(id: String) {

}

})
```

```kotlin
// Get one image from camera
val dir = File(externalCacheDir, "images")
if (!dir.exists()) {
dir.mkdirs()
}

val cameraTempFile = File(dir, System.currentTimeMillis().toString() + ".jpg")
val uri = FileProvider.getUriForFile(this@PickerActivity, "$packageName.provider", cameraTempFile)
Picker.camera().image().output(uri, cameraTempFile)
.go(this@PickerActivity, object : SingleCallback {
override fun onGet(id: String, uri: Uri, file: File) {
adapter!!.add(FileImpl(file)).autoNotify()
}

override fun onCancel(id: String) {

}

})
```

With this library, you can get images easily from gallery and camera. Support getting multiple images and videos from gallery, and getting one image or video from camera.

## SAFR[ ![Download](https://api.bintray.com/packages/boybeak/nulldreams/safr/images/download.svg) ](https://bintray.com/boybeak/nulldreams/safr/_latestVersion)

```groovy
implementation 'com.github.boybeak:safr:x.y.z'
```

**SAFR** is short for **startActivityForResult**.

```kotlin
SAFR.newInstance().extras {
//fill data here
}.byAction(Intent.ACTION_GET_CONTENT)
.startActivityForResult(this, 100, object : Callback {
override fun onResult(requestCode: Int, resultCode: Int, data: Intent?) {

}

})
```