├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── dotengine │ │ └── linsir │ │ └── basedevelop │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── dotengine │ │ │ └── linsir │ │ │ └── basedevelop │ │ │ ├── BaseRecyclerViewAdapterActivity.java │ │ │ ├── EventBusActivity.java │ │ │ ├── GlideActivity.java │ │ │ ├── GlideTransFormationActivity.java │ │ │ ├── LoggerActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── MaterialDialogActivity.java │ │ │ ├── MyApplication.java │ │ │ ├── NoHttpActivity.java │ │ │ └── TastyToastActivity.java │ └── res │ │ ├── layout │ │ ├── activity_base_adapter.xml │ │ ├── activity_eventbus.xml │ │ ├── activity_glide.xml │ │ ├── activity_glide_transformat.xml │ │ ├── activity_main.xml │ │ ├── activity_md_dialogs.xml │ │ ├── activity_nohttp.xml │ │ ├── activity_tasty_toast.xml │ │ ├── item_recycler_view.xml │ │ └── item_recycler_view2.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── dotengine │ └── linsir │ └── basedevelop │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | Android > Lint > Correctness 39 | 40 | 41 | Android > Lint > Performance 42 | 43 | 44 | Android > Lint > Security 45 | 46 | 47 | Compiler issuesJava 48 | 49 | 50 | GPath inspectionsGroovy 51 | 52 | 53 | Groovy 54 | 55 | 56 | Internationalization issuesJava 57 | 58 | 59 | JSON 60 | 61 | 62 | Java 63 | 64 | 65 | Performance issuesJava 66 | 67 | 68 | Properties Files 69 | 70 | 71 | Properties FilesJava 72 | 73 | 74 | 75 | 76 | Android 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 98 | 99 | 100 | 101 | 102 | 103 | 108 | 109 | 110 | 111 | 112 | 113 | 1.7 114 | 115 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 131 | 132 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android中能够简化开发流程的一些框架 2 | 3 | > 本文介绍的是一些博主在开发过程中经常用到的Android开源框架,所谓开源框架我的理解就是别人封装好的代码,可以直接拿过来使用,并且源码也全部公开的代码库。 4 | > 我对于开源框架的使用的态度是,如果完全符合我们项目的需求,或者可定制化的程度非常高的话,那么便可以拿过来直接用,因为开源框架的源码都在那里,如果遇到和项目预期不一样的地方我们也可以把源码拿过来自己改一下,然后重新打个包嘛。 5 | > 但是,不是很建议刚开始学习安卓的小伙伴们,只会用第三方框架,但是不理解框架内部的实现,在用第三方框架的过程中,我们是可以自己先封装一下简单的框架的,然后再了解一下别人框架内部实现的逻辑什么样的,知其所以然嘛。 6 | > 同时也非常感谢这些开源框架的作者们,他们的开源精神,真的是非常的伟大啊。 7 | 8 | ## 网络框架 9 | - [NoHttp](https://github.com/yanzhenjie/NoHttp) 10 | - [RxJava](https://github.com/ReactiveX/RxJava) + [retrofit](https://github.com/square/retrofit) 11 | - [Okhttp](https://github.com/square/okhttp) 12 | - [okhttp-OkGo](https://github.com/jeasonlzy/okhttp-OkGo) 13 | 14 | ## Json解析框架 15 | - [fastJson](https://github.com/alibaba/fastjson) 16 | - [gson](https://github.com/google/gson) 17 | 18 | ## 图片加载框架 19 | - [fresco](https://github.com/facebook/fresco) 20 | - [Glide](https://github.com/bumptech/glide) 21 | - [picasso](https://github.com/square/picasso) 22 | 23 | ## Log类的库 24 | - [logger](https://github.com/orhanobut/logger) 25 | - [KLog](https://github.com/ZhaoKaiQiang/KLog) 26 | - [xLog](https://github.com/elvishew/xLog) 27 | 28 | ## RecyclerView 29 | - [UltimateRecyclerView](https://github.com/cymcsg/UltimateRecyclerView) 30 | - [IndexRecyclerView](https://github.com/jiang111/IndexRecyclerView) 31 | - [recyclerview-animators](https://github.com/wasabeef/recyclerview-animators) 32 | 33 | ## Adapter 34 | - [BaseRecyclerViewAdapterHelper](https://github.com/CymChad/BaseRecyclerViewAdapterHelper) 35 | - [baseAdapter](https://github.com/hongyangAndroid/baseAdapter) 36 | - [base-adapter-helper](https://github.com/JoanZapata/base-adapter-helper) 37 | 38 | ## 数据库 39 | - [greenDAO](https://github.com/greenrobot/greenDAO) 40 | - [realm-java](https://github.com/realm/realm-java) 41 | - [ormlite-android](https://github.com/j256/ormlite-android) 42 | 43 | ## 注解库 44 | - [butterknife](https://github.com/JakeWharton/butterknife) 45 | - [xUtils3](https://github.com/wyouflf/xUtils3) 46 | - [annotations](http://androidannotations.org/) 47 | 48 | ## 事件总线 49 | - [EventBus](https://github.com/greenrobot/EventBus) 50 | - [RxJava](https://github.com/ReactiveX/RxJava) 51 | 52 | ## 图片剪裁 53 | - [uCrop](https://github.com/Yalantis/uCrop) 54 | - [android-crop](https://github.com/jdamcd/android-crop) 55 | - [glide-transformations](https://github.com/wasabeef/glide-transformations) 56 | 57 | ## 性能检测 58 | - [leakcanary](https://github.com/square/leakcanary) 59 | 60 | ## 后台任务队列 61 | - [tape](https://github.com/square/tape) 62 | 63 | ## UI 64 | - [Android-Bootstrap](https://github.com/Bearded-Hen/Android-Bootstrap) 65 | - [material-dialogs](https://github.com/afollestad/material-dialogs) 66 | - [Android-PickerView](https://github.com/Bigkoo/Android-PickerView) 67 | - [TastyToast](https://github.com/yadav-rahul/TastyToast) 68 | - [awesome-android-ui](https://github.com/wasabeef/awesome-android-ui) 69 | 70 | 71 | ---- 72 | 73 | > 感觉这么给大家介绍完了,可能大家会感觉到很抽象,所以打算动手撸一个小的项目,让大家具体感受一下大神们封装的库 74 | 75 | [项目源码下载](https://github.com/linsir6/BaseDevelop) 76 | 77 | ### 项目中用到的库: 78 | 79 | * nohttp 80 | * butterknife 81 | * glide 82 | * logger 83 | * BaseRecyclerViewAdapterHelper 84 | * eventbus 85 | * glide-transformations 86 | * leakcanary 87 | * Android-Bootstrap 88 | * TastyToast 89 | * material-dialogs 90 | 91 | 92 | 项目截图: 93 | ![效果图](https://ws2.sinaimg.cn/large/006tNbRwly1ffs86hx2c2j30k00zkjum.jpg) 94 | 95 | 96 | nohttp: 97 | 98 | ``` 99 | //同步请求,结果直接存储在了response 100 | Request request = NoHttp.createStringRequest("自己的url", RequestMethod.POST); 101 | Response response = NoHttp.startRequestSync(request); 102 | String result = response.get(); 103 | //可以直接将结果取出,并且内置了Gson,fastJson,可以直接将结果转换成对应的model 104 | 105 | 106 | 107 | 108 | //异步请求,可以构建请求队列,默认同时三个请求一起,参数可调 109 | RequestQueue requestQueue = NoHttp.newRequestQueue(); 110 | 111 | OnResponseListener listener = new OnResponseListener() { 112 | @Override public void onStart(int what) { 113 | 114 | } 115 | 116 | @Override public void onSucceed(int what, Response response) { 117 | 118 | } 119 | 120 | @Override public void onFailed(int what, Response response) { 121 | 122 | } 123 | 124 | @Override public void onFinish(int what) { 125 | 126 | } 127 | }; 128 | 129 | //请求String 130 | Request request2 = NoHttp.createStringRequest("自己的url", RequestMethod.GET); 131 | requestQueue.add(0, request2, listener); 132 | 133 | //可以自定义请求类型 134 | 135 | /* 136 | // JsonObject 137 | Request objRequest = NoHttp.createJsonObjectRequest("自己的url", RequestMethod.POST); 138 | requestQueue.add(0, objRequest, listener); 139 | 140 | // JsonArray 141 | Request arrayRequest = NoHttp.createJsonArrayRequest("自己的url", RequestMethod.PUT); 142 | requestQueue.add(0, arrayRequest, listener); 143 | 144 | 145 | Request request = new FastJsonRequest(url, RequestMethod.POST); 146 | requestQueue.add(0, request, listener); 147 | 148 | // 内部使用Gson、FastJson解析成JavaBean 149 | Request request = new JavaBeanRequest(url, RequestMethod.GET); 150 | requestQueue.add(0, request, listener); 151 | 152 | Request request = new JavaBeanRequest(url, RequestMethod.POST); 153 | .add("name", "yoldada") // String类型 154 | .add("age", 18) // int类型 155 | .add("sex", '0') // char类型 156 | .add("time", 16346468473154) // long类型 157 | 158 | // 添加Bitmap 159 | .add("head", new BitmapBinary(bitmap)) 160 | // 添加File 161 | .add("head", new FileBinary(file)) 162 | // 添加ByteArray 163 | .add("head", new ByteArrayBinary(byte[])) 164 | // 添加InputStream 165 | .add("head", new InputStreamBinary(inputStream)); 166 | 167 | */ 168 | 169 | 170 | //nohttp同时有非常完备的缓存的策略,同时对文件上传,请求包体都有非常好的兼容,并且全都是中文文档~ 171 | ``` 172 | 173 | 174 | butterknife: 175 | 176 | ``` 177 | @BindView(R.id.title) TextView title; 178 | 179 | @Override 180 | protected void onCreate(Bundle savedInstanceState) { 181 | super.onCreate(savedInstanceState); 182 | setContentView(R.layout.activity_main); 183 | ButterKnife.bind(this); 184 | title.setText("一些第三方库的测试的demo"); 185 | 186 | 187 | } 188 | 189 | @OnClick(R.id.nohttp) public void onNohttpClicked() { 190 | startActivity(new Intent(MainActivity.this, NoHttpActivity.class)); 191 | } 192 | 193 | @OnClick(R.id.glide) public void onGlideClicked() { 194 | startActivity(new Intent(MainActivity.this,GlideActivity.class)); 195 | } 196 | 197 | @OnClick(R.id.baseRecyclerview_adapter_helper) public void onBaseRecyclerviewAdapterHelperClicked() { 198 | startActivity(new Intent(MainActivity.this,BaseRecyclerViewAdapterActivity.class)); 199 | } 200 | 201 | @OnClick(R.id.event_bus) public void onEventBusClicked() { 202 | startActivity(new Intent(MainActivity.this,EventBusActivity.class)); 203 | } 204 | 205 | @OnClick(R.id.glide_transformations) public void onGlideTransformationsClicked() { 206 | startActivity(new Intent(MainActivity.this,GlideTransFormationActivity.class)); 207 | } 208 | 209 | @OnClick(R.id.tasty_toast) public void onTastyToastClicked() { 210 | startActivity(new Intent(MainActivity.this,TastyToastActivity.class)); 211 | } 212 | 213 | @OnClick(R.id.material_dialogs) public void onMaterialDialogsClicked() { 214 | startActivity(new Intent(MainActivity.this,MaterialDialogActivity.class)); 215 | } 216 | 217 | @OnClick(R.id.logger) public void onLoggerClicked() { 218 | startActivity(new Intent(MainActivity.this,LoggerActivity.class)); 219 | } 220 | 221 | 222 | ``` 223 | 224 | glide: 225 | 226 | ``` 227 | Glide.with(this).load("http://goo.gl/gEgYUd").into(img1); 228 | 229 | 230 | Glide.with(this) 231 | .load("http://goo.gl/gEgYUd") 232 | .fitCenter() 233 | .centerCrop() 234 | .into(img2); 235 | 236 | 237 | Glide.with(this) 238 | .load("") 239 | .fitCenter() 240 | .centerCrop() 241 | .error(R.mipmap.ic_launcher) 242 | .into(img3); 243 | 244 | Glide.with(this) 245 | .load("http://goo.gl/gEgYUd") 246 | .diskCacheStrategy(DiskCacheStrategy.ALL) 247 | .into(img4); 248 | 249 | Glide.with(this) 250 | .load("http://goo.gl/gEgYUd") 251 | .crossFade() 252 | .into(img5); 253 | 254 | Glide.with(this) 255 | .load("http://goo.gl/gEgYUd") 256 | .into(new SimpleTarget() { 257 | @Override public void onResourceReady(GlideDrawable resource, GlideAnimation glideAnimation) { 258 | 259 | img6.setImageDrawable(resource); 260 | } 261 | }); 262 | ``` 263 | 264 | ![glide效果图](https://ws2.sinaimg.cn/large/006tNbRwly1ffs892r469j30k00zkgnn.jpg) 265 | 266 | 267 | logger: 268 | 269 | ``` 270 | Logger.d("hello"); 271 | Logger.d("hello %s %d", "world", 5); // String.format 272 | Logger.d("hello"); 273 | Logger.e("hello"); 274 | Logger.w("hello"); 275 | Logger.v("hello"); 276 | Logger.wtf("hello"); 277 | 278 | // Logger.json(JSON_CONTENT); //打印json 279 | // Logger.xml(XML_CONTENT); 280 | // Logger.log(DEBUG, "tag", "message", throwable); 281 | // Logger.d("hello %s", "world"); 282 | // 283 | // Logger.d(list); //打印list 284 | // Logger.d(map); 285 | // Logger.d(set); 286 | // Logger.d(new String[]); 287 | // 288 | // Logger 289 | // .init(YOUR_TAG) // default PRETTYLOGGER or use just init() 290 | // .methodCount(3) // default 2 291 | // .hideThreadInfo() // default shown 292 | // .logLevel(LogLevel.NONE) // default LogLevel.FULL 293 | // .methodOffset(2) // default 0 294 | // .logAdapter(new AndroidLogAdapter()); //default AndroidLogAdapter 295 | // 296 | // 297 | // 298 | Logger.log(5000, "tag", "内容", null);//延时打log 299 | ``` 300 | 301 | 302 | ![效果图](https://ws3.sinaimg.cn/large/006tNbRwly1ffs8a54fz8j30uk0smn4c.jpg) 303 | 304 | 305 | 306 | 307 | BaseRecyclerViewAdapterHelper: 308 | 309 | ``` 310 | MultipleItem item1 = new MultipleItem(1, "aaa"); 311 | MultipleItem item2 = new MultipleItem(1, "bbb"); 312 | MultipleItem item3 = new MultipleItem(1, "ccc"); 313 | MultipleItem item4 = new MultipleItem(1, "ddd"); 314 | 315 | MultipleItem item5 = new MultipleItem(2, ""); 316 | MultipleItem item6 = new MultipleItem(2, ""); 317 | 318 | 319 | List list = new ArrayList(); 320 | 321 | list.add(item1); 322 | list.add(item2); 323 | list.add(item5); 324 | list.add(item3); 325 | list.add(item4); 326 | list.add(item6); 327 | 328 | 329 | MultipleItemQuickAdapter adapter = new MultipleItemQuickAdapter(list); 330 | adapter.setSpanSizeLookup(new BaseQuickAdapter.SpanSizeLookup() { 331 | @Override public int getSpanSize(GridLayoutManager gridLayoutManager, int position) { 332 | if (position == 2 || position == 5) { 333 | return 4; 334 | } else { 335 | return 2; 336 | } 337 | } 338 | }); 339 | recyclerView.setLayoutManager(new GridLayoutManager(this, 4)); 340 | recyclerView.setAdapter(adapter); 341 | 342 | //轻松实现多种布局,点击事件等 343 | //添加动画等 344 | 345 | 346 | adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {//item点击事件 347 | @Override public void onItemClick(BaseQuickAdapter adapter, View view, int position) { 348 | Toast.makeText(BaseRecyclerViewAdapterActivity.this, "点击了" + position, Toast.LENGTH_SHORT).show(); 349 | } 350 | }); 351 | 352 | //adapter.addHeaderView();添加headerview 353 | 354 | //可以优化Adapter代码 355 | //添加Item事件 356 | //添加列表加载动画 357 | //添加头部、尾部 358 | //自动加载 359 | //添加分组 360 | //自定义不同的item类型 361 | //设置空布局 362 | //添加拖拽、滑动删除 363 | //分组的伸缩栏 364 | //自定义ViewHolder 365 | } 366 | 367 | public class MultipleItem implements MultiItemEntity { 368 | public static final int TEXT = 1; 369 | public static final int IMG = 2; 370 | public String text; 371 | private int itemType; 372 | 373 | public MultipleItem(int itemType, String text) { 374 | this.itemType = itemType; 375 | this.text = text; 376 | } 377 | 378 | @Override 379 | public int getItemType() { 380 | return itemType; 381 | } 382 | } 383 | 384 | public class MultipleItemQuickAdapter extends BaseMultiItemQuickAdapter { 385 | 386 | public MultipleItemQuickAdapter(List data) { 387 | super(data); 388 | addItemType(MultipleItem.TEXT, R.layout.item_recycler_view); 389 | addItemType(MultipleItem.IMG, R.layout.item_recycler_view2); 390 | } 391 | 392 | @Override 393 | protected void convert(BaseViewHolder helper, MultipleItem item) { 394 | switch (helper.getItemViewType()) { 395 | case MultipleItem.TEXT: 396 | helper.setText(R.id.text, item.text); 397 | break; 398 | case MultipleItem.IMG: 399 | //可以在这里面设置图片,现在默认是背景图片 400 | break; 401 | } 402 | } 403 | 404 | } 405 | ``` 406 | 407 | ![baseAdapter效果图](https://ws1.sinaimg.cn/large/006tNbRwly1ffs8d7egelj30k00zkab8.jpg) 408 | 409 | 410 | eventbus: 411 | 412 | ``` 413 | //当然,我们目前将,发送与接收放在了一个界面里面,他们可以在不同的界面里面,可以实现app内部的通信 414 | 415 | @Override protected void onStart() { 416 | super.onStart(); 417 | EventBus.getDefault().register(this); 418 | } 419 | 420 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) { 421 | super.onCreate(savedInstanceState); 422 | setContentView(R.layout.activity_eventbus); 423 | ButterKnife.bind(this); 424 | } 425 | 426 | @Subscribe(threadMode = ThreadMode.MAIN) 427 | public void onMessageEvent(MessageEvent event) { 428 | Toast.makeText(EventBusActivity.this, "收到的内容 -> " + event.event, Toast.LENGTH_SHORT).show(); 429 | } 430 | 431 | 432 | @Override protected void onDestroy() { 433 | EventBus.getDefault().unregister(this); 434 | super.onDestroy(); 435 | } 436 | 437 | @OnClick(R.id.send) public void onViewClicked() { 438 | EventBus.getDefault().post(new MessageEvent("今天好开心")); 439 | } 440 | 441 | public class MessageEvent{ 442 | String event; 443 | 444 | public MessageEvent(String event){ 445 | this.event = event; 446 | } 447 | 448 | } 449 | ``` 450 | 451 | ![eventBus效果图](https://ws1.sinaimg.cn/large/006tNbRwly1ffs8ee7l0ij30k00zkdgk.jpg) 452 | 453 | 454 | 455 | 456 | glide-transformations: 457 | 458 | ``` 459 | //可以修改颜色,加滤镜,剪裁,gpu加速等 460 | 461 | Glide.with(this).load("https://ws1.sinaimg.cn/large/006tNbRwly1ffs6l68mx3j30ge0gen08.jpg") 462 | .bitmapTransform(new BlurTransformation(this, 30), new CropCircleTransformation(this)) 463 | .into((ImageView) findViewById(R.id.img1)); 464 | 465 | Glide.with(this).load("https://ws1.sinaimg.cn/large/006tNbRwly1ffs6l68mx3j30ge0gen08.jpg") 466 | .bitmapTransform(new CropCircleTransformation(this)) 467 | .into((ImageView) findViewById(R.id.img2)); 468 | 469 | Glide.with(this).load("https://ws1.sinaimg.cn/large/006tNbRwly1ffs6l68mx3j30ge0gen08.jpg") 470 | .bitmapTransform(new CropSquareTransformation(this)) 471 | .into((ImageView) findViewById(R.id.img3)); 472 | 473 | Glide.with(this).load("https://ws1.sinaimg.cn/large/006tNbRwly1ffs6l68mx3j30ge0gen08.jpg") 474 | .bitmapTransform(new ColorFilterTransformation(this, 0x80dfdfdf)) 475 | .into((ImageView) findViewById(R.id.img4)); 476 | 477 | ``` 478 | 479 | ![glide-transformations效果图](https://ws3.sinaimg.cn/large/006tNbRwly1ffs8fll7j8j30k00zkq6e.jpg) 480 | 481 | 482 | leakcanary: 483 | 484 | ``` 485 | /* 486 | * LeakCanary用来专注分析系统的进程 487 | */ 488 | 489 | if (LeakCanary.isInAnalyzerProcess(this)) { 490 | return; 491 | } 492 | ``` 493 | 494 | ![检测是否有内存泄漏](https://ws1.sinaimg.cn/large/006tNbRwly1ffs8hbi2u2j30jg0a43zd.jpg) 495 | 496 | 497 | Android-Bootstrap: 498 | 499 | ``` 500 | 501 | 511 | 512 | 513 | 520 | 521 | 525 | 526 | 527 | 539 | 540 | 552 | 553 | 565 | 566 | 578 | 579 | 590 | 591 | 603 | 604 | 616 | 617 | 629 | 630 | 631 | 632 | 633 | 634 | ``` 635 | 636 | ![bootstrap效果图](https://ws2.sinaimg.cn/large/006tNbRwly1ffs86hx2c2j30k00zkjum.jpg) 637 | 638 | TastyToast: 639 | 640 | ``` 641 | 642 | @OnClick(R.id.button1) public void onButton1Clicked() { 643 | TastyToast.makeText(getApplicationContext(), "Hello World !", TastyToast.LENGTH_LONG, TastyToast.WARNING); 644 | } 645 | 646 | @OnClick(R.id.button2) public void onButton2Clicked() { 647 | TastyToast.makeText(getApplicationContext(), "Hello World !", TastyToast.LENGTH_LONG, TastyToast.CONFUSING); 648 | } 649 | 650 | @OnClick(R.id.button3) public void onButton3Clicked() { 651 | TastyToast.makeText(getApplicationContext(), "Hello World !", TastyToast.LENGTH_LONG, TastyToast.DEFAULT); 652 | } 653 | 654 | @OnClick(R.id.button4) public void onButton4Clicked() { 655 | TastyToast.makeText(getApplicationContext(), "Hello World !", TastyToast.LENGTH_LONG, TastyToast.ERROR); 656 | } 657 | 658 | @OnClick(R.id.button5) public void onButton5Clicked() { 659 | TastyToast.makeText(getApplicationContext(), "Hello World !", TastyToast.LENGTH_LONG, TastyToast.INFO); 660 | } 661 | 662 | @OnClick(R.id.button6) public void onButton6Clicked() { 663 | TastyToast.makeText(getApplicationContext(), "Hello World !", TastyToast.LENGTH_LONG, TastyToast.SUCCESS); 664 | } 665 | ``` 666 | 667 | ![TastyToast效果图](https://ws3.sinaimg.cn/large/006tNbRwly1ffs8k9wg7tj30k00zkjst.jpg) 668 | 669 | ![TastyToast效果图](https://ws3.sinaimg.cn/large/006tNbRwly1ffs8kqfpxjj30k00zk3zy.jpg) 670 | 671 | material-dialogs: 672 | 673 | ``` 674 | @OnClick(R.id.button1) public void onButton1Clicked() { 675 | new MaterialDialog.Builder(this) 676 | .title("标题") 677 | .content("是否同意") 678 | .positiveText("同意") 679 | .onPositive(new MaterialDialog.SingleButtonCallback() { 680 | @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { 681 | Toast.makeText(MaterialDialogActivity.this, "同意", Toast.LENGTH_SHORT).show(); 682 | 683 | } 684 | }) 685 | .negativeText("不同意") 686 | .onNegative(new MaterialDialog.SingleButtonCallback() { 687 | @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { 688 | Toast.makeText(MaterialDialogActivity.this, "不同意", Toast.LENGTH_SHORT).show(); 689 | } 690 | }) 691 | .show(); 692 | } 693 | 694 | @OnClick(R.id.button2) public void onButton2Clicked() { 695 | MaterialDialog.Builder builder = new MaterialDialog.Builder(this) 696 | .title("标题") 697 | .content("是否同意") 698 | .positiveText("同意"); 699 | 700 | MaterialDialog dialog = builder.build(); 701 | dialog.show(); 702 | //dialog.dismiss(); 703 | } 704 | 705 | @OnClick(R.id.button3) public void onButton3Clicked() { 706 | new MaterialDialog.Builder(this) 707 | .title("标题") 708 | .content("是否同意") 709 | .positiveText("1111") 710 | .negativeText("2222") 711 | .neutralText("3333") 712 | .show(); 713 | } 714 | 715 | @OnClick(R.id.button4) public void onButton4Clicked() { 716 | new MaterialDialog.Builder(this) 717 | .onPositive(new MaterialDialog.SingleButtonCallback() { 718 | @Override 719 | public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { 720 | Toast.makeText(MaterialDialogActivity.this, "1111", Toast.LENGTH_SHORT).show(); 721 | } 722 | }) 723 | .onNeutral(new MaterialDialog.SingleButtonCallback() { 724 | @Override 725 | public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { 726 | Toast.makeText(MaterialDialogActivity.this, "2222", Toast.LENGTH_SHORT).show(); 727 | } 728 | }) 729 | .onNegative(new MaterialDialog.SingleButtonCallback() { 730 | @Override 731 | public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { 732 | Toast.makeText(MaterialDialogActivity.this, "3333", Toast.LENGTH_SHORT).show(); 733 | } 734 | }) 735 | .onAny(new MaterialDialog.SingleButtonCallback() { 736 | @Override 737 | public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { 738 | Toast.makeText(MaterialDialogActivity.this, "4444", Toast.LENGTH_SHORT).show(); 739 | } 740 | }); 741 | } 742 | 743 | @OnClick(R.id.button5) public void onButton5Clicked() { 744 | new MaterialDialog.Builder(this) 745 | .iconRes(R.mipmap.ic_launcher) 746 | .limitIconToDefaultSize() 747 | .title("test") 748 | .positiveText("allow") 749 | .negativeText("deny") 750 | .onAny(new MaterialDialog.SingleButtonCallback() { 751 | @Override 752 | public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { 753 | Toast.makeText(MaterialDialogActivity.this, "Prompt checked? " + dialog.isPromptCheckBoxChecked(), Toast.LENGTH_SHORT).show(); 754 | } 755 | }) 756 | .checkBoxPromptRes(R.string.app_name, false, null) 757 | .show(); 758 | } 759 | 760 | @OnClick(R.id.button6) public void onButton6Clicked() { 761 | new MaterialDialog.Builder(this) 762 | .title("test") 763 | .items(R.array.good) 764 | .itemsCallback(new MaterialDialog.ListCallback() { 765 | @Override 766 | public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { 767 | Toast.makeText(MaterialDialogActivity.this, "点击的是 " + which, Toast.LENGTH_SHORT).show(); 768 | } 769 | }) 770 | .show(); 771 | } 772 | 773 | @OnClick(R.id.button7) public void onButton7Clicked() { 774 | new MaterialDialog.Builder(this) 775 | .title("test") 776 | .items(R.array.good) 777 | .itemsCallbackSingleChoice(-1, new MaterialDialog.ListCallbackSingleChoice() { 778 | @Override 779 | public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { 780 | /** 781 | * If you use alwaysCallSingleChoiceCallback(), which is discussed below, 782 | * returning false here won't allow the newly selected radio button to actually be selected. 783 | **/ 784 | return true; 785 | } 786 | }) 787 | .positiveText(R.string.app_name) 788 | .show(); 789 | } 790 | ``` 791 | 792 | 793 | ![MD_DIALOG效果图](https://ws3.sinaimg.cn/large/006tNbRwly1ffs8qiu2khj30k00zkjsr.jpg) 794 | 795 | ![MD_DIALOG效果图](https://ws2.sinaimg.cn/large/006tNbRwly1ffs8lehyvrj30k00zkmy9.jpg) 796 | 797 | 798 | [项目源码下载](https://github.com/linsir6/BaseDevelop) 799 | 800 | 801 | ---- 802 | 803 | 804 | 以上便是对这些库的一个小的总结,大家如果感觉这些库不错的话,建议上github上面看一下他们的文档,可以学到更多的用法,并且可以看到他们的源码。希望大家同样可以上github给我star,或者follow~ 805 | [项目源码下载](https://github.com/linsir6/BaseDevelop) 806 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | //=============以下为butterknife需要============== 3 | apply plugin: 'com.jakewharton.butterknife' 4 | //============================================== 5 | 6 | 7 | 8 | android { 9 | compileSdkVersion 25 10 | buildToolsVersion "25.0.2" 11 | defaultConfig { 12 | applicationId "com.dotengine.linsir.basedevelop" 13 | minSdkVersion 19 14 | targetSdkVersion 25 15 | versionCode 1 16 | versionName "1.0" 17 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 18 | } 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | } 26 | 27 | dependencies { 28 | compile fileTree(include: ['*.jar'], dir: 'libs') 29 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 30 | exclude group: 'com.android.support', module: 'support-annotations' 31 | }) 32 | compile 'com.android.support:appcompat-v7:25.3.1' 33 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 34 | testCompile 'junit:junit:4.12' 35 | //=============以下为nohttp所需引入的包============= 36 | compile 'com.yanzhenjie.nohttp:nohttp:1.1.2' 37 | compile 'com.yanzhenjie.nohttp:okhttp:1.1.2' 38 | //============================================== 39 | 40 | //=============以下为butterknife需要============== 41 | compile 'com.jakewharton:butterknife:8.5.1' 42 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' 43 | //============================================== 44 | 45 | //================以下为Glide需要================= 46 | compile 'com.github.bumptech.glide:glide:3.7.0' 47 | compile 'com.android.support:support-v4:25.3.1' 48 | //============================================== 49 | 50 | //================以下为logger需要================ 51 | compile 'com.orhanobut:logger:1.15' 52 | //============================================== 53 | //=====以下为BaseRecyclerViewAdapterHelper需要==== 54 | compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.15' 55 | //============================================== 56 | 57 | //===============以下为eventbus需要=============== 58 | compile 'org.greenrobot:eventbus:3.0.0' 59 | //============================================== 60 | 61 | //===========以下为transformations需要============ 62 | compile 'jp.wasabeef:glide-transformations:2.0.2' 63 | // If you want to use the GPU Filters 64 | compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1' 65 | //============================================== 66 | 67 | //==================leakcanary================== 68 | debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1' 69 | releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1' 70 | testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1' 71 | //============================================== 72 | 73 | //===============androidbootstrap=============== 74 | compile 'com.beardedhen:androidbootstrap:2.3.1' 75 | //============================================== 76 | 77 | //==================tastytoast================== 78 | compile 'com.sdsmdg.tastytoast:tastytoast:0.1.1' 79 | //============================================== 80 | 81 | //===============material-dialogs=============== 82 | compile 'com.afollestad.material-dialogs:core:0.9.4.5' 83 | //============================================== 84 | 85 | } 86 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/mac/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/dotengine/linsir/basedevelop/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.dotengine.linsir.basedevelop; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.dotengine.linsir.basedevelop", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/dotengine/linsir/basedevelop/BaseRecyclerViewAdapterActivity.java: -------------------------------------------------------------------------------- 1 | package com.dotengine.linsir.basedevelop; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.support.v7.widget.GridLayoutManager; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.view.View; 9 | import android.widget.Toast; 10 | 11 | import com.chad.library.adapter.base.BaseMultiItemQuickAdapter; 12 | import com.chad.library.adapter.base.BaseQuickAdapter; 13 | import com.chad.library.adapter.base.BaseViewHolder; 14 | import com.chad.library.adapter.base.entity.MultiItemEntity; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | import butterknife.BindView; 20 | import butterknife.ButterKnife; 21 | 22 | /** 23 | * Created by linSir 24 | * date at 2017/5/20. 25 | * describe: 26 | */ 27 | 28 | public class BaseRecyclerViewAdapterActivity extends AppCompatActivity { 29 | 30 | @BindView(R.id.recycler_view) RecyclerView recyclerView; 31 | 32 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) { 33 | super.onCreate(savedInstanceState); 34 | setContentView(R.layout.activity_base_adapter); 35 | ButterKnife.bind(this); 36 | MultipleItem item1 = new MultipleItem(1, "aaa"); 37 | MultipleItem item2 = new MultipleItem(1, "bbb"); 38 | MultipleItem item3 = new MultipleItem(1, "ccc"); 39 | MultipleItem item4 = new MultipleItem(1, "ddd"); 40 | 41 | MultipleItem item5 = new MultipleItem(2, ""); 42 | MultipleItem item6 = new MultipleItem(2, ""); 43 | 44 | 45 | List list = new ArrayList(); 46 | 47 | list.add(item1); 48 | list.add(item2); 49 | list.add(item5); 50 | list.add(item3); 51 | list.add(item4); 52 | list.add(item6); 53 | 54 | 55 | MultipleItemQuickAdapter adapter = new MultipleItemQuickAdapter(list); 56 | adapter.setSpanSizeLookup(new BaseQuickAdapter.SpanSizeLookup() { 57 | @Override public int getSpanSize(GridLayoutManager gridLayoutManager, int position) { 58 | if (position == 2 || position == 5) { 59 | return 4; 60 | } else { 61 | return 2; 62 | } 63 | } 64 | }); 65 | recyclerView.setLayoutManager(new GridLayoutManager(this, 4)); 66 | recyclerView.setAdapter(adapter); 67 | 68 | //轻松实现多种布局,点击事件等 69 | //添加动画等 70 | 71 | 72 | adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {//item点击事件 73 | @Override public void onItemClick(BaseQuickAdapter adapter, View view, int position) { 74 | Toast.makeText(BaseRecyclerViewAdapterActivity.this, "点击了" + position, Toast.LENGTH_SHORT).show(); 75 | } 76 | }); 77 | 78 | //adapter.addHeaderView();添加headerview 79 | 80 | //可以优化Adapter代码 81 | //添加Item事件 82 | //添加列表加载动画 83 | //添加头部、尾部 84 | //自动加载 85 | //添加分组 86 | //自定义不同的item类型 87 | //设置空布局 88 | //添加拖拽、滑动删除 89 | //分组的伸缩栏 90 | //自定义ViewHolder 91 | } 92 | 93 | public class MultipleItem implements MultiItemEntity { 94 | public static final int TEXT = 1; 95 | public static final int IMG = 2; 96 | public String text; 97 | private int itemType; 98 | 99 | public MultipleItem(int itemType, String text) { 100 | this.itemType = itemType; 101 | this.text = text; 102 | } 103 | 104 | @Override 105 | public int getItemType() { 106 | return itemType; 107 | } 108 | } 109 | 110 | public class MultipleItemQuickAdapter extends BaseMultiItemQuickAdapter { 111 | 112 | public MultipleItemQuickAdapter(List data) { 113 | super(data); 114 | addItemType(MultipleItem.TEXT, R.layout.item_recycler_view); 115 | addItemType(MultipleItem.IMG, R.layout.item_recycler_view2); 116 | } 117 | 118 | @Override 119 | protected void convert(BaseViewHolder helper, MultipleItem item) { 120 | switch (helper.getItemViewType()) { 121 | case MultipleItem.TEXT: 122 | helper.setText(R.id.text, item.text); 123 | break; 124 | case MultipleItem.IMG: 125 | //可以在这里面设置图片,现在默认是背景图片 126 | break; 127 | } 128 | } 129 | 130 | } 131 | 132 | } 133 | -------------------------------------------------------------------------------- /app/src/main/java/com/dotengine/linsir/basedevelop/EventBusActivity.java: -------------------------------------------------------------------------------- 1 | package com.dotengine.linsir.basedevelop; 2 | 3 | import android.os.Bundle; 4 | import android.os.Message; 5 | import android.support.annotation.Nullable; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.widget.Toast; 8 | 9 | import org.greenrobot.eventbus.EventBus; 10 | import org.greenrobot.eventbus.Subscribe; 11 | import org.greenrobot.eventbus.ThreadMode; 12 | 13 | import butterknife.ButterKnife; 14 | import butterknife.OnClick; 15 | 16 | /** 17 | * Created by linSir 18 | * date at 2017/5/20. 19 | * describe: 20 | */ 21 | 22 | public class EventBusActivity extends AppCompatActivity { 23 | 24 | //当然,我们目前将,发送与接收放在了一个界面里面,他们可以在不同的界面里面,可以实现app内部的通信 25 | 26 | @Override protected void onStart() { 27 | super.onStart(); 28 | EventBus.getDefault().register(this); 29 | } 30 | 31 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | setContentView(R.layout.activity_eventbus); 34 | ButterKnife.bind(this); 35 | } 36 | 37 | @Subscribe(threadMode = ThreadMode.MAIN) 38 | public void onMessageEvent(MessageEvent event) { 39 | Toast.makeText(EventBusActivity.this, "收到的内容 -> " + event.event, Toast.LENGTH_SHORT).show(); 40 | } 41 | 42 | 43 | @Override protected void onDestroy() { 44 | EventBus.getDefault().unregister(this); 45 | super.onDestroy(); 46 | } 47 | 48 | @OnClick(R.id.send) public void onViewClicked() { 49 | EventBus.getDefault().post(new MessageEvent("今天好开心")); 50 | } 51 | 52 | public class MessageEvent{ 53 | String event; 54 | 55 | public MessageEvent(String event){ 56 | this.event = event; 57 | } 58 | 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/java/com/dotengine/linsir/basedevelop/GlideActivity.java: -------------------------------------------------------------------------------- 1 | package com.dotengine.linsir.basedevelop; 2 | 3 | import android.graphics.drawable.BitmapDrawable; 4 | import android.graphics.drawable.Drawable; 5 | import android.os.Bundle; 6 | import android.support.annotation.Nullable; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.widget.ImageView; 9 | 10 | import com.bumptech.glide.Glide; 11 | import com.bumptech.glide.load.engine.DiskCacheStrategy; 12 | import com.bumptech.glide.load.resource.drawable.GlideDrawable; 13 | import com.bumptech.glide.request.Request; 14 | import com.bumptech.glide.request.animation.GlideAnimation; 15 | import com.bumptech.glide.request.target.SimpleTarget; 16 | import com.bumptech.glide.request.target.SizeReadyCallback; 17 | import com.bumptech.glide.request.target.Target; 18 | 19 | import butterknife.BindView; 20 | import butterknife.ButterKnife; 21 | 22 | /** 23 | * Created by linSir 24 | * date at 2017/5/20. 25 | * describe: glide库的demo 26 | */ 27 | 28 | public class GlideActivity extends AppCompatActivity { 29 | 30 | @BindView(R.id.img1) ImageView img1; 31 | @BindView(R.id.img2) ImageView img2; 32 | @BindView(R.id.img3) ImageView img3; 33 | @BindView(R.id.img4) ImageView img4; 34 | @BindView(R.id.img5) ImageView img5; 35 | @BindView(R.id.img6) ImageView img6; 36 | 37 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) { 38 | super.onCreate(savedInstanceState); 39 | setContentView(R.layout.activity_glide); 40 | ButterKnife.bind(this); 41 | 42 | Glide.with(this).load("http://goo.gl/gEgYUd").into(img1); 43 | 44 | 45 | Glide.with(this) 46 | .load("http://goo.gl/gEgYUd") 47 | .fitCenter() 48 | .centerCrop() 49 | .into(img2); 50 | 51 | 52 | Glide.with(this) 53 | .load("") 54 | .fitCenter() 55 | .centerCrop() 56 | .error(R.mipmap.ic_launcher) 57 | .into(img3); 58 | 59 | Glide.with(this) 60 | .load("http://goo.gl/gEgYUd") 61 | .diskCacheStrategy(DiskCacheStrategy.ALL) 62 | .into(img4); 63 | 64 | Glide.with(this) 65 | .load("http://goo.gl/gEgYUd") 66 | .crossFade() 67 | .into(img5); 68 | 69 | Glide.with(this) 70 | .load("http://goo.gl/gEgYUd") 71 | .into(new SimpleTarget() { 72 | @Override public void onResourceReady(GlideDrawable resource, GlideAnimation glideAnimation) { 73 | 74 | img6.setImageDrawable(resource); 75 | } 76 | }); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app/src/main/java/com/dotengine/linsir/basedevelop/GlideTransFormationActivity.java: -------------------------------------------------------------------------------- 1 | package com.dotengine.linsir.basedevelop; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.widget.ImageView; 7 | 8 | import com.bumptech.glide.Glide; 9 | 10 | import butterknife.BindView; 11 | import butterknife.ButterKnife; 12 | import jp.wasabeef.glide.transformations.BlurTransformation; 13 | import jp.wasabeef.glide.transformations.ColorFilterTransformation; 14 | import jp.wasabeef.glide.transformations.CropCircleTransformation; 15 | import jp.wasabeef.glide.transformations.CropSquareTransformation; 16 | 17 | /** 18 | * Created by linSir 19 | * date at 2017/5/20. 20 | * describe: 21 | */ 22 | 23 | public class GlideTransFormationActivity extends AppCompatActivity { 24 | 25 | @BindView(R.id.img1) ImageView img1; 26 | @BindView(R.id.img2) ImageView img2; 27 | @BindView(R.id.img3) ImageView img3; 28 | @BindView(R.id.img4) ImageView img4; 29 | 30 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) { 31 | super.onCreate(savedInstanceState); 32 | setContentView(R.layout.activity_glide_transformat); 33 | ButterKnife.bind(this); 34 | 35 | //可以修改颜色,加滤镜,剪裁,gpu加速等 36 | 37 | Glide.with(this).load("https://ws1.sinaimg.cn/large/006tNbRwly1ffs6l68mx3j30ge0gen08.jpg") 38 | .bitmapTransform(new BlurTransformation(this, 30), new CropCircleTransformation(this)) 39 | .into((ImageView) findViewById(R.id.img1)); 40 | 41 | Glide.with(this).load("https://ws1.sinaimg.cn/large/006tNbRwly1ffs6l68mx3j30ge0gen08.jpg") 42 | .bitmapTransform(new CropCircleTransformation(this)) 43 | .into((ImageView) findViewById(R.id.img2)); 44 | 45 | Glide.with(this).load("https://ws1.sinaimg.cn/large/006tNbRwly1ffs6l68mx3j30ge0gen08.jpg") 46 | .bitmapTransform(new CropSquareTransformation(this)) 47 | .into((ImageView) findViewById(R.id.img3)); 48 | 49 | Glide.with(this).load("https://ws1.sinaimg.cn/large/006tNbRwly1ffs6l68mx3j30ge0gen08.jpg") 50 | .bitmapTransform(new ColorFilterTransformation(this, 0x80dfdfdf)) 51 | .into((ImageView) findViewById(R.id.img4)); 52 | 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/dotengine/linsir/basedevelop/LoggerActivity.java: -------------------------------------------------------------------------------- 1 | package com.dotengine.linsir.basedevelop; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v7.app.AppCompatActivity; 6 | 7 | import com.orhanobut.logger.Logger; 8 | 9 | /** 10 | * Created by linSir 11 | * date at 2017/5/20. 12 | * describe: 13 | */ 14 | 15 | public class LoggerActivity extends AppCompatActivity { 16 | 17 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | Logger.d("hello"); 20 | Logger.d("hello %s %d", "world", 5); // String.format 21 | Logger.d("hello"); 22 | Logger.e("hello"); 23 | Logger.w("hello"); 24 | Logger.v("hello"); 25 | Logger.wtf("hello"); 26 | 27 | // Logger.json(JSON_CONTENT); //打印json 28 | // Logger.xml(XML_CONTENT); 29 | // Logger.log(DEBUG, "tag", "message", throwable); 30 | // Logger.d("hello %s", "world"); 31 | // 32 | // Logger.d(list); //打印list 33 | // Logger.d(map); 34 | // Logger.d(set); 35 | // Logger.d(new String[]); 36 | // 37 | // Logger 38 | // .init(YOUR_TAG) // default PRETTYLOGGER or use just init() 39 | // .methodCount(3) // default 2 40 | // .hideThreadInfo() // default shown 41 | // .logLevel(LogLevel.NONE) // default LogLevel.FULL 42 | // .methodOffset(2) // default 0 43 | // .logAdapter(new AndroidLogAdapter()); //default AndroidLogAdapter 44 | // 45 | // 46 | // 47 | Logger.log(5000, "tag", "内容", null);//延时打log 48 | } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/dotengine/linsir/basedevelop/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.dotengine.linsir.basedevelop; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.widget.TextView; 7 | 8 | 9 | import butterknife.BindView; 10 | import butterknife.ButterKnife; 11 | import butterknife.OnClick; 12 | 13 | public class MainActivity extends AppCompatActivity { 14 | 15 | @BindView(R.id.title) TextView title; 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_main); 21 | ButterKnife.bind(this); 22 | title.setText("一些第三方库的测试的demo"); 23 | 24 | 25 | } 26 | 27 | @OnClick(R.id.nohttp) public void onNohttpClicked() { 28 | startActivity(new Intent(MainActivity.this, NoHttpActivity.class)); 29 | } 30 | 31 | @OnClick(R.id.glide) public void onGlideClicked() { 32 | startActivity(new Intent(MainActivity.this,GlideActivity.class)); 33 | } 34 | 35 | @OnClick(R.id.baseRecyclerview_adapter_helper) public void onBaseRecyclerviewAdapterHelperClicked() { 36 | startActivity(new Intent(MainActivity.this,BaseRecyclerViewAdapterActivity.class)); 37 | } 38 | 39 | @OnClick(R.id.event_bus) public void onEventBusClicked() { 40 | startActivity(new Intent(MainActivity.this,EventBusActivity.class)); 41 | } 42 | 43 | @OnClick(R.id.glide_transformations) public void onGlideTransformationsClicked() { 44 | startActivity(new Intent(MainActivity.this,GlideTransFormationActivity.class)); 45 | } 46 | 47 | @OnClick(R.id.tasty_toast) public void onTastyToastClicked() { 48 | startActivity(new Intent(MainActivity.this,TastyToastActivity.class)); 49 | } 50 | 51 | @OnClick(R.id.material_dialogs) public void onMaterialDialogsClicked() { 52 | startActivity(new Intent(MainActivity.this,MaterialDialogActivity.class)); 53 | } 54 | 55 | @OnClick(R.id.logger) public void onLoggerClicked() { 56 | startActivity(new Intent(MainActivity.this,LoggerActivity.class)); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/dotengine/linsir/basedevelop/MaterialDialogActivity.java: -------------------------------------------------------------------------------- 1 | package com.dotengine.linsir.basedevelop; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.NonNull; 5 | import android.support.annotation.Nullable; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.view.View; 8 | import android.widget.Toast; 9 | 10 | import com.afollestad.materialdialogs.DialogAction; 11 | import com.afollestad.materialdialogs.MaterialDialog; 12 | 13 | import butterknife.ButterKnife; 14 | import butterknife.OnClick; 15 | 16 | /** 17 | * Created by linSir 18 | * date at 2017/5/20. 19 | * describe: 20 | */ 21 | 22 | public class MaterialDialogActivity extends AppCompatActivity { 23 | 24 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | setContentView(R.layout.activity_md_dialogs); 27 | ButterKnife.bind(this); 28 | 29 | } 30 | 31 | @OnClick(R.id.button1) public void onButton1Clicked() { 32 | new MaterialDialog.Builder(this) 33 | .title("标题") 34 | .content("是否同意") 35 | .positiveText("同意") 36 | .onPositive(new MaterialDialog.SingleButtonCallback() { 37 | @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { 38 | Toast.makeText(MaterialDialogActivity.this, "同意", Toast.LENGTH_SHORT).show(); 39 | 40 | } 41 | }) 42 | .negativeText("不同意") 43 | .onNegative(new MaterialDialog.SingleButtonCallback() { 44 | @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { 45 | Toast.makeText(MaterialDialogActivity.this, "不同意", Toast.LENGTH_SHORT).show(); 46 | } 47 | }) 48 | .show(); 49 | } 50 | 51 | @OnClick(R.id.button2) public void onButton2Clicked() { 52 | MaterialDialog.Builder builder = new MaterialDialog.Builder(this) 53 | .title("标题") 54 | .content("是否同意") 55 | .positiveText("同意"); 56 | 57 | MaterialDialog dialog = builder.build(); 58 | dialog.show(); 59 | //dialog.dismiss(); 60 | } 61 | 62 | @OnClick(R.id.button3) public void onButton3Clicked() { 63 | new MaterialDialog.Builder(this) 64 | .title("标题") 65 | .content("是否同意") 66 | .positiveText("1111") 67 | .negativeText("2222") 68 | .neutralText("3333") 69 | .show(); 70 | } 71 | 72 | @OnClick(R.id.button4) public void onButton4Clicked() { 73 | new MaterialDialog.Builder(this) 74 | .onPositive(new MaterialDialog.SingleButtonCallback() { 75 | @Override 76 | public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { 77 | Toast.makeText(MaterialDialogActivity.this, "1111", Toast.LENGTH_SHORT).show(); 78 | } 79 | }) 80 | .onNeutral(new MaterialDialog.SingleButtonCallback() { 81 | @Override 82 | public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { 83 | Toast.makeText(MaterialDialogActivity.this, "2222", Toast.LENGTH_SHORT).show(); 84 | } 85 | }) 86 | .onNegative(new MaterialDialog.SingleButtonCallback() { 87 | @Override 88 | public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { 89 | Toast.makeText(MaterialDialogActivity.this, "3333", Toast.LENGTH_SHORT).show(); 90 | } 91 | }) 92 | .onAny(new MaterialDialog.SingleButtonCallback() { 93 | @Override 94 | public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { 95 | Toast.makeText(MaterialDialogActivity.this, "4444", Toast.LENGTH_SHORT).show(); 96 | } 97 | }); 98 | } 99 | 100 | @OnClick(R.id.button5) public void onButton5Clicked() { 101 | new MaterialDialog.Builder(this) 102 | .iconRes(R.mipmap.ic_launcher) 103 | .limitIconToDefaultSize() 104 | .title("test") 105 | .positiveText("allow") 106 | .negativeText("deny") 107 | .onAny(new MaterialDialog.SingleButtonCallback() { 108 | @Override 109 | public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { 110 | Toast.makeText(MaterialDialogActivity.this, "Prompt checked? " + dialog.isPromptCheckBoxChecked(), Toast.LENGTH_SHORT).show(); 111 | } 112 | }) 113 | .checkBoxPromptRes(R.string.app_name, false, null) 114 | .show(); 115 | } 116 | 117 | @OnClick(R.id.button6) public void onButton6Clicked() { 118 | new MaterialDialog.Builder(this) 119 | .title("test") 120 | .items(R.array.good) 121 | .itemsCallback(new MaterialDialog.ListCallback() { 122 | @Override 123 | public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { 124 | Toast.makeText(MaterialDialogActivity.this, "点击的是 " + which, Toast.LENGTH_SHORT).show(); 125 | } 126 | }) 127 | .show(); 128 | } 129 | 130 | @OnClick(R.id.button7) public void onButton7Clicked() { 131 | new MaterialDialog.Builder(this) 132 | .title("test") 133 | .items(R.array.good) 134 | .itemsCallbackSingleChoice(-1, new MaterialDialog.ListCallbackSingleChoice() { 135 | @Override 136 | public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { 137 | /** 138 | * If you use alwaysCallSingleChoiceCallback(), which is discussed below, 139 | * returning false here won't allow the newly selected radio button to actually be selected. 140 | **/ 141 | return true; 142 | } 143 | }) 144 | .positiveText(R.string.app_name) 145 | .show(); 146 | } 147 | 148 | 149 | } 150 | -------------------------------------------------------------------------------- /app/src/main/java/com/dotengine/linsir/basedevelop/MyApplication.java: -------------------------------------------------------------------------------- 1 | package com.dotengine.linsir.basedevelop; 2 | 3 | import android.app.Application; 4 | 5 | import com.beardedhen.androidbootstrap.TypefaceProvider; 6 | import com.squareup.leakcanary.LeakCanary; 7 | import com.yanzhenjie.nohttp.Logger; 8 | import com.yanzhenjie.nohttp.NoHttp; 9 | import com.yanzhenjie.nohttp.OkHttpNetworkExecutor; 10 | import com.yanzhenjie.nohttp.cookie.DBCookieStore; 11 | 12 | /** 13 | * Created by linSir 14 | * date at 2017/5/16. 15 | * describe: 16 | */ 17 | 18 | public class MyApplication extends Application { 19 | 20 | @Override public void onCreate() { 21 | super.onCreate(); 22 | 23 | /* 24 | * LeakCanary用来专注分析系统的进程 25 | */ 26 | 27 | if (LeakCanary.isInAnalyzerProcess(this)) { 28 | return; 29 | } 30 | 31 | TypefaceProvider.registerDefaultIconSets(); 32 | 33 | LeakCanary.install(this); 34 | 35 | NoHttp.initialize(this, new NoHttp.Config() 36 | // 默认保存数据库DBCookieStore,开发者也可以自己实现CookieStore接口。 37 | .setCookieStore( 38 | new DBCookieStore(this).setEnable(false) // 如果不维护cookie,设置false禁用。 39 | 40 | ) 41 | .setNetworkExecutor(new OkHttpNetworkExecutor()) 42 | ); 43 | 44 | Logger.setDebug(true);// 开启NoHttp的调试模式, 配置后可看到请求过程、日志和错误信息。 45 | Logger.setTag("NoHttpSample");// 设置NoHttp打印Log的tag。 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/dotengine/linsir/basedevelop/NoHttpActivity.java: -------------------------------------------------------------------------------- 1 | package com.dotengine.linsir.basedevelop; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v7.app.AppCompatActivity; 6 | 7 | import com.yanzhenjie.nohttp.NoHttp; 8 | import com.yanzhenjie.nohttp.RequestMethod; 9 | import com.yanzhenjie.nohttp.rest.OnResponseListener; 10 | import com.yanzhenjie.nohttp.rest.Request; 11 | import com.yanzhenjie.nohttp.rest.RequestQueue; 12 | import com.yanzhenjie.nohttp.rest.Response; 13 | 14 | /** 15 | * Created by linSir 16 | * date at 2017/5/20. 17 | * describe: noHttp的demo 18 | */ 19 | 20 | public class NoHttpActivity extends AppCompatActivity { 21 | 22 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | setContentView(R.layout.activity_nohttp); 25 | 26 | //同步请求,结果直接存储在了response 27 | Request request = NoHttp.createStringRequest("自己的url", RequestMethod.POST); 28 | Response response = NoHttp.startRequestSync(request); 29 | String result = response.get(); 30 | //可以直接将结果取出,并且内置了Gson,fastJson,可以直接将结果转换成对应的model 31 | 32 | 33 | 34 | 35 | //异步请求,可以构建请求队列,默认同时三个请求一起,参数可调 36 | RequestQueue requestQueue = NoHttp.newRequestQueue(); 37 | 38 | OnResponseListener listener = new OnResponseListener() { 39 | @Override public void onStart(int what) { 40 | 41 | } 42 | 43 | @Override public void onSucceed(int what, Response response) { 44 | 45 | } 46 | 47 | @Override public void onFailed(int what, Response response) { 48 | 49 | } 50 | 51 | @Override public void onFinish(int what) { 52 | 53 | } 54 | }; 55 | 56 | //请求String 57 | Request request2 = NoHttp.createStringRequest("自己的url", RequestMethod.GET); 58 | requestQueue.add(0, request2, listener); 59 | 60 | //可以自定义请求类型 61 | 62 | /* 63 | // JsonObject 64 | Request objRequest = NoHttp.createJsonObjectRequest("自己的url", RequestMethod.POST); 65 | requestQueue.add(0, objRequest, listener); 66 | 67 | // JsonArray 68 | Request arrayRequest = NoHttp.createJsonArrayRequest("自己的url", RequestMethod.PUT); 69 | requestQueue.add(0, arrayRequest, listener); 70 | 71 | 72 | Request request = new FastJsonRequest(url, RequestMethod.POST); 73 | requestQueue.add(0, request, listener); 74 | 75 | // 内部使用Gson、FastJson解析成JavaBean 76 | Request request = new JavaBeanRequest(url, RequestMethod.GET); 77 | requestQueue.add(0, request, listener); 78 | 79 | Request request = new JavaBeanRequest(url, RequestMethod.POST); 80 | .add("name", "yoldada") // String类型 81 | .add("age", 18) // int类型 82 | .add("sex", '0') // char类型 83 | .add("time", 16346468473154) // long类型 84 | 85 | // 添加Bitmap 86 | .add("head", new BitmapBinary(bitmap)) 87 | // 添加File 88 | .add("head", new FileBinary(file)) 89 | // 添加ByteArray 90 | .add("head", new ByteArrayBinary(byte[])) 91 | // 添加InputStream 92 | .add("head", new InputStreamBinary(inputStream)); 93 | 94 | */ 95 | 96 | 97 | //nohttp同时有非常完备的缓存的策略,同时对文件上传,请求包体都有非常好的兼容,并且全都是中文文档~ 98 | 99 | 100 | 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /app/src/main/java/com/dotengine/linsir/basedevelop/TastyToastActivity.java: -------------------------------------------------------------------------------- 1 | package com.dotengine.linsir.basedevelop; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v7.app.AppCompatActivity; 6 | 7 | import com.sdsmdg.tastytoast.TastyToast; 8 | 9 | import butterknife.ButterKnife; 10 | import butterknife.OnClick; 11 | 12 | /** 13 | * Created by linSir 14 | * date at 2017/5/20. 15 | * describe: tastyToast库的测试类 16 | */ 17 | 18 | public class TastyToastActivity extends AppCompatActivity { 19 | 20 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) { 21 | super.onCreate(savedInstanceState); 22 | setContentView(R.layout.activity_tasty_toast); 23 | ButterKnife.bind(this); 24 | 25 | } 26 | 27 | @OnClick(R.id.button1) public void onButton1Clicked() { 28 | TastyToast.makeText(getApplicationContext(), "Hello World !", TastyToast.LENGTH_LONG, TastyToast.WARNING); 29 | } 30 | 31 | @OnClick(R.id.button2) public void onButton2Clicked() { 32 | TastyToast.makeText(getApplicationContext(), "Hello World !", TastyToast.LENGTH_LONG, TastyToast.CONFUSING); 33 | } 34 | 35 | @OnClick(R.id.button3) public void onButton3Clicked() { 36 | TastyToast.makeText(getApplicationContext(), "Hello World !", TastyToast.LENGTH_LONG, TastyToast.DEFAULT); 37 | } 38 | 39 | @OnClick(R.id.button4) public void onButton4Clicked() { 40 | TastyToast.makeText(getApplicationContext(), "Hello World !", TastyToast.LENGTH_LONG, TastyToast.ERROR); 41 | } 42 | 43 | @OnClick(R.id.button5) public void onButton5Clicked() { 44 | TastyToast.makeText(getApplicationContext(), "Hello World !", TastyToast.LENGTH_LONG, TastyToast.INFO); 45 | } 46 | 47 | @OnClick(R.id.button6) public void onButton6Clicked() { 48 | TastyToast.makeText(getApplicationContext(), "Hello World !", TastyToast.LENGTH_LONG, TastyToast.SUCCESS); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_base_adapter.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 20 | 21 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_eventbus.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 |