Skip to content

Commit

Permalink
Approve Activity
Browse files Browse the repository at this point in the history
#12
- to take url for retrofit api from preferences SettingActivity.java
  • Loading branch information
eurosecom committed May 13, 2017
1 parent 7196326 commit 5876f77
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ public boolean test(String query) throws Exception {

private void getAbsServer(String fromfir) {
showProgressBar();
subscription = AbsServerClient.getInstance()
String urlx = SettingsActivity.getServerName(AbsServerAsActivity.this);
subscription = AbsServerClient.getInstance(urlx)
.getAbsServer(fromfir)
.subscribeOn(rx.schedulers.Schedulers.io())
.observeOn(rx.android.schedulers.AndroidSchedulers.mainThread())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ private void writeKeyfToServer(String usico, String usid, String ume, String dmx
DatabaseReference mDatabase, String keyf, String cplxb ) {

String getfromfir = SettingsActivity.getFir(AbsServerAsBaseSearchActivity.this);
subscription = AbsServerClient.getInstance()
String urlx = SettingsActivity.getServerName(AbsServerAsBaseSearchActivity.this);
subscription = AbsServerClient.getInstance(urlx)
.setKeyAndgetAbsServer(getfromfir, keyf, cplxb)
.subscribeOn(rx.schedulers.Schedulers.io())
.observeOn(rx.android.schedulers.AndroidSchedulers.mainThread())
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/com/eusecom/attendance/FbmessClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
public class FbmessClient {

private static final String FCM_BASE_URL = "https://fcm.googleapis.com";
private static final String GITHUB_BASE_URL = "https://api.github.com/";

private static FbmessClient instance;
private FbmessService fbmessService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,11 @@ public class ApproveListFragment extends Fragment {
// [END define_database_reference]

public ApproveListFragment() {}
String absxy;
String abskeydel=null;
private ProgressDialog fProgressDialog;
boolean isCancelable, isrunning;
boolean isCancelable;
String timestampx;

private RfEtestApi _githubService;
private RfEtestApi _rfetestService;
private CompositeDisposable _disposables;

private Subscription subscription;
Expand Down Expand Up @@ -116,7 +114,7 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String githubToken = Constants.ETEST_API_KEY;
String urlx = SettingsActivity.getServerName(getActivity());
_githubService = RfEtestService.createGithubService(githubToken, urlx);
_rfetestService = RfEtestService.createGithubService(githubToken, urlx);

_disposables = new CompositeDisposable();

Expand Down Expand Up @@ -263,10 +261,10 @@ private void approveAbsenceToServer(String postkey, int anodaj, Attendance model
String savetofir = SettingsActivity.getFir(getActivity());
String whoapprove = SettingsActivity.getUsOsc(getActivity());

_disposables.add(_githubService.contributors(savetofir, postkey, whoapprove, approveabs_json, anodaj)
_disposables.add(_rfetestService.contributors(savetofir, postkey, whoapprove, approveabs_json, anodaj)
.flatMap(Observable::fromIterable)
.flatMap(contributor -> {
Observable<RfUser> _userObservable = _githubService.user(savetofir, postkey, whoapprove, approveabs_json, anodaj, contributor.login)
Observable<RfUser> _userObservable = _rfetestService.user(savetofir, postkey, whoapprove, approveabs_json, anodaj, contributor.login)
.filter(user -> !isEmpty(user.name) && !isEmpty(user.email));

return Observable.zip(_userObservable,
Expand Down Expand Up @@ -304,10 +302,10 @@ public void onNext(Pair pair) {

if(contributor.saved == 1 ) {
snext = getResources().getString(R.string.abs_saved) + snextx;
approveAbsenceToFB(abskeydel, contributor.anodaj, model);
approveAbsenceToFB(postkey, contributor.anodaj, model);
}else{
snext = getResources().getString(R.string.abs_savednot);
approveAbsenceToFB(abskeydel, contributor.anodaj, model);
approveAbsenceToFB(postkey, contributor.anodaj, model);
}


Expand Down Expand Up @@ -336,7 +334,7 @@ private void getApproveDialog(String postkey, Attendance model) {
long timestampdo = Long.parseLong(model.dado) * 1000L;
String datedos = getDate(timestampdo );

String textx = model.usname + " " + model.dmxa + " " + model.dmna + " " + dateods + " / " + datedos;
String textx = postkey + model.usname + " " + model.dmxa + " " + model.dmna + " " + dateods + " / " + datedos;
TextView text = (TextView) dialog.findViewById(R.id.text);
text.setText(textx);
ImageView image = (ImageView) dialog.findViewById(R.id.image);
Expand All @@ -349,9 +347,9 @@ private void getApproveDialog(String postkey, Attendance model) {
public void onClick(View v) {
dialog.dismiss();
if(savetofiri>0){
approveAbsenceToServer(abskeydel, 1, model);
approveAbsenceToServer(postkey, 1, model);
}else{
approveAbsenceToFB(abskeydel, 1, model);
approveAbsenceToFB(postkey, 1, model);
}
}
});
Expand All @@ -362,9 +360,9 @@ public void onClick(View v) {
public void onClick(View v) {
dialog.dismiss();
if(savetofiri>0){
approveAbsenceToServer(abskeydel, 0, model);
approveAbsenceToServer(postkey, 0, model);
}else{
approveAbsenceToFB(abskeydel, 0, model);
approveAbsenceToFB(postkey, 0, model);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.support.annotation.NonNull;

import com.eusecom.attendance.Constants;
import com.eusecom.attendance.models.Attendance;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
Expand All @@ -18,14 +19,13 @@
*/
public class AbsServerClient {

//https://api.github.com/users/arriolac/starred
//private static final String ABSSERVER_BASE_URL = "https://api.github.com/";
private static final String ABSSERVER_BASE_URL = "http://www.eshoptest.sk";

private static AbsServerClient instance;
private AbsServerService absServerService;

private AbsServerClient() {
private AbsServerClient(String urlx) {

final String ABSSERVER_BASE_URL = urlx;
final Gson gson =
new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
final Retrofit retrofit = new Retrofit.Builder().baseUrl(ABSSERVER_BASE_URL)
Expand All @@ -35,9 +35,9 @@ private AbsServerClient() {
absServerService = retrofit.create(AbsServerService.class);
}

public static AbsServerClient getInstance() {
public static AbsServerClient getInstance(String urlx) {
if (instance == null) {
instance = new AbsServerClient();
instance = new AbsServerClient(urlx);
}
return instance;
}
Expand Down

0 comments on commit 5876f77

Please sign in to comment.