-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
blades
committed
Oct 26, 2016
1 parent
6eba84b
commit 8ba77df
Showing
4 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package library.blades.rxcore; | ||
|
||
/** | ||
* ClassName: Captain<p> | ||
* Author: blades<p> | ||
* Des: Captain<p> | ||
* CreateTime: 2016/10/20 14:32<p> | ||
* UpdateTime: 2016/10/20 14:32<p> | ||
* GitHub: https://github.com/AlphaKnife | ||
*/ | ||
|
||
public class Captain { | ||
|
||
/** | ||
* cap_id : 168105 | ||
* sal_id : 637 | ||
* cap_name : 测试 | ||
* add_time : 2016-09-21 16:01:23 | ||
* cap_tel : 13541253654 | ||
* dial_num : 0 | ||
* last_time : 0 | ||
* is_cap : 1 | ||
*/ | ||
|
||
public String cap_id; | ||
public String sal_id; | ||
public String cap_name; | ||
public String add_time; | ||
public String cap_tel; | ||
public String dial_num; | ||
public String last_time; | ||
public String is_cap; | ||
|
||
@Override | ||
public String toString() { | ||
return "Captain{" + | ||
"cap_id='" + cap_id + '\'' + | ||
", sal_id='" + sal_id + '\'' + | ||
", cap_name='" + cap_name + '\'' + | ||
", add_time='" + add_time + '\'' + | ||
", cap_tel='" + cap_tel + '\'' + | ||
", dial_num='" + dial_num + '\'' + | ||
", last_time='" + last_time + '\'' + | ||
", is_cap='" + is_cap + '\'' + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package library.blades.rxcore; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.reflect.TypeToken; | ||
import com.rxandroidnetworking.RxAndroidNetworking; | ||
|
||
import java.lang.reflect.Type; | ||
|
||
import rx.Observable; | ||
import rx.android.schedulers.AndroidSchedulers; | ||
import rx.functions.Func1; | ||
import rx.schedulers.Schedulers; | ||
|
||
/** | ||
* ClassName: RManager<p> | ||
* Author: blades<p> | ||
* Des: RManager<p> | ||
* CreateTime: 2016/10/20 14:41<p> | ||
* UpdateTime: 2016/10/20 14:41<p> | ||
* GitHub: https://github.com/AlphaKnife | ||
*/ | ||
|
||
public class RManager { | ||
|
||
|
||
public static <T> Observable<BaseEntity<T>> getData(Observable<String> obserable) { | ||
return obserable.map(new Func1<String, BaseEntity<T>>() { | ||
@Override | ||
public BaseEntity<T> call(String s) { | ||
Gson gson = new Gson(); | ||
Type type = new TypeToken<BaseEntity<T>>() { | ||
}.getType(); | ||
|
||
return gson.fromJson(s, type); | ||
} | ||
}).subscribeOn(Schedulers.io()) | ||
.observeOn(AndroidSchedulers.mainThread()); | ||
} | ||
|
||
public static Observable<String> create(String url) { | ||
return RxAndroidNetworking | ||
.get(url) | ||
.build() | ||
.getStringObservable(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package library.blades.rxcore; | ||
|
||
/** | ||
* ClassName: User<p> | ||
* Author: blades<p> | ||
* Des: User<p> | ||
* CreateTime: 2016/10/20 14:15<p> | ||
* UpdateTime: 2016/10/20 14:15<p> | ||
* GitHub: https://github.com/AlphaKnife | ||
*/ | ||
|
||
public class User { | ||
|
||
/** | ||
* id : 1 | ||
* firstname : Amit | ||
* lastname : Shekhar | ||
*/ | ||
|
||
public String id; | ||
public String firstname; | ||
public String lastname; | ||
|
||
@Override | ||
public String toString() { | ||
return "User{" + | ||
"id='" + id + '\'' + | ||
", firstname='" + firstname + '\'' + | ||
", lastname='" + lastname + '\'' + | ||
'}'; | ||
} | ||
} |