Skip to content

Commit

Permalink
custom dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
SiberiaDante committed Sep 19, 2017
1 parent 4e69f3f commit e8e4622
Show file tree
Hide file tree
Showing 29 changed files with 497 additions and 179 deletions.
35 changes: 3 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,16 @@
* [email:994537867@qq.com] [siberiadante@gmail.com]
* 关注我的微信公众号: [tstongxiao]
![微信公众号图片](/sample/src/main/assets/images/qrcode.jpg)
## 推荐
### [Android开发必备经典收藏集(整理中)]
### [TitleLayout——通用万能标题栏]
### [CustomDialog——通用万能Dialog]
## gradle依赖方法
* Step 1.Add it in your root build.gradle at the end of repositories:

```
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```
* Step 2. Add the dependency

```
dependencies {
compile 'com.github.SibreiaDante:SiberiaDanteLib:1.0.2'
}
```
## maven依赖方法
* Step 1.Add the JitPack repository to your build file
```
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
```
* Step 2.Add the dependency
```
<dependency>
<groupId>com.github.SibreiaDante</groupId>
<artifactId>SiberiaDanteLib</artifactId>
<version>1.0.2</version>
</dependency>
```
## module依赖方法
下载SiberiaDante,以module的方式导入项目,在build.gradle中添加代码:compile project(':siberiadante')
### 说明
* 使用之前需要在Application中初始化SiberiaDanteLib.initLib(context);
* 开启Debug模式:SiberiaDanteLib.setDebug(true);
Expand Down
2 changes: 1 addition & 1 deletion customapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ android {
minifyEnabled true
shrinkResources true
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'proguard-fresco.pro'
}
debug {
minifyEnabled true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,10 @@ Observable<WrapResult<List<NewsData>>> newsApi(@Field("access_token") String acc
@Field("page") String page,
@Field("count") String count);


@FormUrlEncoded
@POST("api/news")
Observable<WrapResult<List<NewsData>>> newsApiA(@FieldMap Map<String, String> map);


@POST("api/news")
Observable<WrapResult<List<NewsData>>> newsApiT(@Body RequestBody body);

@POST("api/login")
@POST("api/authorization")
Observable<WrapResult<LoginResponse>> getLoginApi(@FieldMap Map<String, String> map);

@POST("api/authorization")
Observable<WrapResult<LoginResponse>> getLoginApiB(@Body RequestBody body);
}
16 changes: 9 additions & 7 deletions customapp/src/main/java/com/siberiadante/custom/http/Params.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.siberiadante.custom.constant.Constants;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
Expand All @@ -18,18 +19,19 @@
* @GitHub: https://github.com/SiberiaDante
*/

class Params {
class Params {

static RequestBody getNews(int page, int count) {
Map<String, String> map = new TreeMap<>();
static RequestBody getLoginParams(String username, String psd) {
HashMap<String, String> map = new HashMap<>();
map.put("access_token", Constants.ACCESS_TOKEN);
map.put("method", Constants.METHOD_GET);
map.put("page", String.valueOf(page));
map.put("method", String.valueOf(count));
map.put("method", Constants.METHOD_POST);
map.put("username", username);
map.put("password", psd);
map.put("type", "mobile");
return paramsData(map);
}

static RequestBody paramsData(Map<String, String> map) {
static RequestBody paramsData(HashMap<String, String> map) {
return RequestBody.create(MediaType.parse("application/x-www-form-urlencoded"), map.toString());
}

Expand Down
14 changes: 10 additions & 4 deletions customapp/src/main/java/com/siberiadante/custom/http/Request.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.siberiadante.custom.http;

import com.siberiadante.custom.bean.LoginResponse;
import com.siberiadante.custom.bean.NewsData;
import com.siberiadante.custom.bean.base.WrapResult;

Expand All @@ -22,11 +23,16 @@ public class Request {
private ObservableTransformer transformer = RetrofitManager.getInstance().BaseTransformer();

public static Request getInstance() {
return new Request();
return RequestHolder.request;
}

public Observable<WrapResult<List<NewsData>>> getNewsData(int page, int count) {
RequestBody requestBody = Params.getNews(page, count);
return apiService.newsApiT(requestBody).compose(transformer);
private static class RequestHolder {
private static final Request request = new Request();
}

public Observable<WrapResult<LoginResponse>> getLoginParams(String username, String psd) {
RequestBody requestBody = Params.getLoginParams(username, psd);
return apiService.getLoginApiB(requestBody).compose(transformer);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ protected void addCompositeDisposable(Disposable disposable) {
if (null != disposable) {
mCompositeDisposable.add(disposable);
}

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;

import com.siberiadante.custom.R;
import com.siberiadante.custom.bean.LoginResponse;
import com.siberiadante.custom.bean.NewsData;
import com.siberiadante.custom.bean.base.WrapResult;
import com.siberiadante.custom.constant.Constants;
import com.siberiadante.custom.http.ApiService;
import com.siberiadante.custom.http.Request;
import com.siberiadante.custom.http.RetrofitManager;
import com.siberiadante.lib.util.LogUtil;
import com.siberiadante.lib.util.ToastUtil;
import com.siberiadante.lib.view.TitleBar;

import java.util.HashMap;
import java.util.List;

import io.reactivex.Observer;
Expand Down Expand Up @@ -69,77 +75,80 @@ private void initView() {
}

private void initIntent() {
getNewsData(mPage);
getLoginTest();
getLoginTest2();
}

private void getNewsData(int mPage) {
private void getLoginTest2() {

Request.getInstance().getNewsData(1, 20)
Request.getInstance().getLoginParams("15122835113", "123456")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<WrapResult<List<NewsData>>>() {
.subscribe(new Observer<WrapResult<LoginResponse>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
LogUtil.d(TAG, "-----onSubscribe-----");
LogUtil.d(TAG, "---------------------onSubscribe-----------------------");
}

@Override
public void onNext(@NonNull WrapResult<LoginResponse> listWrapResult) {
LogUtil.d(TAG, "onNext:2222222222222222222----------------------- " + listWrapResult.getInfo());
// adapter = new NewsAdapter(getActivity(), listWrapResult.getData());
// recyclerView.setAdapter(adapter);
mLLProgress.setVisibility(View.GONE);
}

@Override
public void onNext(@NonNull WrapResult<List<NewsData>> listWrapResult) {
LogUtil.d(TAG, listWrapResult.getInfo());
public void onError(@NonNull Throwable e) {
LogUtil.d(TAG, "onError");
}

@Override
public void onComplete() {
LogUtil.d(TAG, "onComplete");
mLLProgress.setVisibility(View.GONE);
}
});
}
private void getLoginTest() {

HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("access_token", Constants.ACCESS_TOKEN);
hashMap.put("method", Constants.METHOD_POST);
hashMap.put("username", "15122835113");
hashMap.put("password", "123456");
hashMap.put("type", "mobile");
RetrofitManager.getInstance().createReq(ApiService.class)
.getLoginApi(hashMap)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<WrapResult<LoginResponse>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
LogUtil.d(TAG, "---------------------onSubscribe-----------------------");
}

@Override
public void onNext(@NonNull WrapResult<LoginResponse> listWrapResult) {
LogUtil.d(TAG, "onNext:11111111111111111----------------------- " + listWrapResult.getInfo());
// adapter = new NewsAdapter(getActivity(), listWrapResult.getData());
// recyclerView.setAdapter(adapter);
mLLProgress.setVisibility(View.GONE);
}

@Override
public void onError(@NonNull Throwable e) {
LogUtil.d(TAG, "-----error-----" + e.getMessage());
LogUtil.d(TAG, "onError");

}

@Override
public void onComplete() {

LogUtil.d(TAG, "onComplete");
mLLProgress.setVisibility(View.GONE);
}
});

// HashMap<String, String> hashMap = new HashMap<>();
// hashMap.put("access_token", Constants.ACCESS_TOKEN);
// hashMap.put("method", Constants.METHOD_GET);
// hashMap.put("page", String.valueOf(mPage));
// hashMap.put("count", String.valueOf(20));
// RetrofitManager.getInstance().createReq(ApiService.class)
// .newsApiA(hashMap)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new Observer<WrapResult<List<NewsData>>>() {
// @Override
// public void onSubscribe(@NonNull Disposable d) {
// LogUtil.d(TAG, "onSubscribe");
// }
//
// @Override
// public void onNext(@NonNull WrapResult<List<NewsData>> listWrapResult) {
// LogUtil.d(TAG, "onNext: ");
// adapter.addRes(listWrapResult.getData());
//// adapter = new NewsAdapter(getActivity(), listWrapResult.getData());
//// recyclerView.setAdapter(adapter);
//
// }
//
// @Override
// public void onError(@NonNull Throwable e) {
// LogUtil.d(TAG, "onError");
//
// }
//
// @Override
// public void onComplete() {
// LogUtil.d(TAG, "onComplete");
// mLLProgress.setVisibility(View.GONE);
// }
// });
}

private void initData() {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/**
* @Created SiberiaDante
* @Describe:
* @Describe: Fresco图片加载框架
* @Time: 2017/9/5
* @Email: 994537867@qq.com
* @GitHub: https://github.com/SiberiaDante
Expand All @@ -25,6 +25,12 @@
public class ImageLoadUtil {


/**
* 设置图片url
*
* @param url
* @param imageView
*/
public static void frescoImage(String url, SimpleDraweeView imageView) {
GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(MyApplication.getInstance().getResources());
GenericDraweeHierarchy hierarchy = builder
Expand All @@ -37,6 +43,12 @@ public static void frescoImage(String url, SimpleDraweeView imageView) {
imageView.setImageURI(url);
}

/**
* 设置图片URL,默认圆角10
*
* @param url
* @param imageView
*/
public static void frescoImageRadius(String url, SimpleDraweeView imageView) {
GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(MyApplication.getInstance().getResources());
GenericDraweeHierarchy hierarchy = builder
Expand All @@ -47,7 +59,25 @@ public static void frescoImageRadius(String url, SimpleDraweeView imageView) {
.build();
imageView.setHierarchy(hierarchy);
imageView.setImageURI(url);
}

/**
* 设置圆角图片URL
*
* @param url
* @param imageView
* @param radius
*/
public static void frescoImageRadius(String url, SimpleDraweeView imageView, int radius) {
GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(MyApplication.getInstance().getResources());
GenericDraweeHierarchy hierarchy = builder
.setFadeDuration(300)
.setPlaceholderImage(R.mipmap.ic_launcher)
.setRoundingParams(new RoundingParams().setCornersRadius(radius))
.setFailureImage(R.mipmap.ic_launcher)
.build();
imageView.setHierarchy(hierarchy);
imageView.setImageURI(url);
}

public static void frescoImageLoad(String uri, SimpleDraweeView simpleDraweeView) {
Expand Down
2 changes: 1 addition & 1 deletion sample/src/main/java/com/sample/constants/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Constants {
public static final String ALBUM_PATH = Environment.getExternalStorageDirectory() + "/sample/";
public static final String URL_SIBERIADANTE_LIB = "https://github.com/SiberiaDante/SiberiaDanteLib";
public static final String URL_TITLE_LAYOUT = "https://github.com/SiberiaDante/TitleLayout";
public static final String URL_RX_JAVA = "http://www.jianshu.com/p/464fa025229e";
public static final String URL_CUSTOM_DIALOG = "https://github.com/SiberiaDante/CustomDialog";


public static final String APP_INFO = "app_info_sp";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void onCheckedChanged(RadioGroup radioGroup, int i) {
switch (i) {
case R.id.rb_home_one:
mViewPager.setCurrentItem(0, false);
mMianTitle.setTitle("SiberiaDanteSiberiaDanteSiberiaDanteSiberiaDante——点我");
mMianTitle.setTitle("SiberiaDante——点我");
break;
case R.id.rb_home_two:
mViewPager.setCurrentItem(1, false);
Expand Down
Loading

0 comments on commit e8e4622

Please sign in to comment.