正在查看: Harvest v2.32 应用的 AllEmployeesActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Harvest v2.32 应用的 AllEmployeesActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.ufields.tracking;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.nfc.NdefRecord;
import android.nfc.NfcAdapter;
import android.nfc.Tag;
import android.nfc.tech.Ndef;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.google.android.material.snackbar.Snackbar;
import com.itextpdf.text.xml.xmp.XmpWriter;
import com.ufields.tracking.Adapters.DrawerItemCustomAdapter;
import com.ufields.tracking.Adapters.ListViewAdapterEmployee;
import com.ufields.tracking.AllEmployeesActivity;
import com.ufields.tracking.App.AppUtils;
import com.ufields.tracking.App.EndPoints;
import com.ufields.tracking.App.MyApplication;
import com.ufields.tracking.DataModels.EmployeeDataModel;
import com.ufields.tracking.DataModels.MenuDataModel;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.Locale;
import kotlin.jvm.internal.ByteCompanionObject;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpConnectionParams;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class AllEmployeesActivity extends AppCompatActivity implements NfcAdapter.ReaderCallback {
private static final String MIME_TEXT_PLAIN = "text/plain";
private static final String TAG = "NfcDemo";
ArrayList<MenuDataModel> drawerItem;
@BindView(R.id.drawerLayoutAllEmployees)
DrawerLayout drawerLayout;
private MenuItem english;
private MenuItem french;
private ListViewAdapterEmployee listViewAdapterEmployee;
@BindView(R.id.listViewMenuAllEmployees)
ListView listViewMenu;
@BindView(R.id.listViewSearchAllEmployees)
ListView listViewSearch;
private Dialog pDialog;
private ProgressBar progressBar;
@BindView(R.id.pulltorefresh)
SwipeRefreshLayout refreshLayout;
@BindView(R.id.searchbar)
EditText searchBarEditText;
private TextView setMessage;
@BindView(R.id.containerToolbar)
LinearLayout snack;
private MenuItem spanish;
@BindView(R.id.toolbar)
Toolbar toolbar;
private TextView toolbarTitle;
ArrayList<EmployeeDataModel> arrayListEDM = new ArrayList<>();
private NfcAdapter mNfcAdapter = null;
private String date = "";
public static void setupForegroundDispatch(NfcAdapter.ReaderCallback readerCallback, Activity activity, NfcAdapter nfcAdapter) {
Bundle bundle = new Bundle();
bundle.putInt("presence", 1000);
nfcAdapter.enableReaderMode(activity, readerCallback, 15, bundle);
}
public static void stopForegroundDispatch(Activity activity, NfcAdapter nfcAdapter) {
nfcAdapter.disableReaderMode(activity);
}
protected void onCreate(Bundle bundle) {
AppUtils.setConfigChange(this);
super.onCreate(bundle);
setContentView(R.layout.activity_all_employees);
ButterKnife.bind(this);
this.date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
this.mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
this.toolbarTitle = (TextView) this.toolbar.findViewById(R.id.toolbarText);
Dialog dialog = new Dialog(this);
this.pDialog = dialog;
dialog.setCanceledOnTouchOutside(false);
this.pDialog.requestWindowFeature(1);
this.pDialog.setContentView(R.layout.progress_dialog);
this.pDialog.setTitle("");
this.progressBar = (ProgressBar) this.pDialog.findViewById(R.id.progress);
this.setMessage = (TextView) this.pDialog.findViewById(R.id.message);
setupToolbar();
ArrayList<MenuDataModel> arrayList = new ArrayList<>();
this.drawerItem = arrayList;
arrayList.add(0, new MenuDataModel(R.drawable.harvest32, getResources().getString(R.string.harvest)));
this.drawerItem.add(1, new MenuDataModel(R.drawable.employee, getResources().getString(R.string.employees)));
this.drawerItem.add(2, new MenuDataModel(R.drawable.logout, getResources().getString(R.string.logout)));
if (getIntent().getBooleanExtra("isQrScannerAvailable", false)) {
this.drawerItem.add(3, new MenuDataModel(R.drawable.barcode, getResources().getString(R.string.scanner)));
this.drawerItem.add(4, new MenuDataModel(R.drawable.version, getResources().getString(R.string.appversion) + " 2.27"));
} else {
this.drawerItem.add(3, new MenuDataModel(R.drawable.version, getResources().getString(R.string.appversion) + " 2.27"));
}
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportActionBar().setHomeButtonEnabled(true);
DrawerItemCustomAdapter drawerItemCustomAdapter = new DrawerItemCustomAdapter(this, R.layout.list_view_item, this.drawerItem);
this.listViewMenu.addHeaderView(getLayoutInflater().inflate(R.layout.list_view_header, (ViewGroup) null));
this.listViewMenu.setAdapter((ListAdapter) drawerItemCustomAdapter);
this.listViewMenu.setOnItemClickListener(new DrawerItemClickListener());
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setupDrawerToggle();
this.refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
public final void onRefresh() {
AllEmployeesActivity.this.m7lambda$onCreate$0$comufieldstrackingAllEmployeesActivity();
}
});
this.searchBarEditText.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable editable) {
}
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
AllEmployeesActivity.this.listViewAdapterEmployee.filter(AllEmployeesActivity.this.searchBarEditText.getText().toString().trim());
}
});
this.listViewSearch.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public final void onItemClick(AdapterView adapterView, View view, int i, long j) {
AllEmployeesActivity.this.m8lambda$onCreate$1$comufieldstrackingAllEmployeesActivity(adapterView, view, i, j);
}
});
}
void m7lambda$onCreate$0$comufieldstrackingAllEmployeesActivity() {
if (isNetworkAvailable()) {
new GetAllEmployeeNew().execute(new String[0]);
this.refreshLayout.setRefreshing(false);
} else {
this.refreshLayout.setRefreshing(false);
updateActivity();
}
}
void m8lambda$onCreate$1$comufieldstrackingAllEmployeesActivity(AdapterView adapterView, View view, int i, long j) {
Intent intent = new Intent(getApplicationContext(), (Class<?>) EmployeeFormActivity.class);
intent.putExtra("employeeId", this.arrayListEDM.get(i).getEmployeeId());
intent.putExtra("firstName", this.arrayListEDM.get(i).getEmployeeFirstName());
intent.putExtra("lastName", this.arrayListEDM.get(i).getEmployeeLastName());
intent.putExtra("NFC", this.arrayListEDM.get(i).getNFC());
intent.putExtra("imageUrl", this.arrayListEDM.get(i).getEmployeePictureUrl());
intent.putExtra("NIP", this.arrayListEDM.get(i).getNIP());
startActivity(intent);
overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
finish();
}
public void showSnackBar(String str) {
Snackbar make = Snackbar.make(this.snack, str, 0);
View view = make.getView();
view.setBackgroundColor(Color.parseColor("#D0021B"));
TextView textView = (TextView) view.findViewById(R.id.snackbar_text);
textView.setGravity(17);
textView.setTextColor(Color.parseColor("#FFFFFF"));
textView.setAllCaps(true);
make.show();
}
public void updateActivity() {
String str;
try {
str = new JSONObject(MyApplication.getInstance().getPrefManager().getOrganizationEmployee().getOrganizationInfo()).getString("_id");
} catch (JSONException e) {
e.printStackTrace();
str = "";
}
if (MyApplication.getInstance().getPrefManager().getEmployees(str) != null) {
JSONArray employees = MyApplication.getInstance().getPrefManager().getEmployees(str);
try {
if (employees.length() != 0) {
this.arrayListEDM.clear();
for (int i = 0; i < employees.length(); i++) {
JSONObject jSONObject = employees.getJSONObject(i);
if (jSONObject.optBoolean("status")) {
if (!jSONObject.isNull("NFC") && !jSONObject.getString("NFC").equalsIgnoreCase("")) {
if (jSONObject.isNull("image") && jSONObject.getString("image").equalsIgnoreCase("")) {
this.arrayListEDM.add(new EmployeeDataModel(jSONObject.getString("_id"), jSONObject.getString("firstName"), jSONObject.getString("lastName"), "", jSONObject.getString("NFC"), jSONObject.getString("NIP")));
}
this.arrayListEDM.add(new EmployeeDataModel(jSONObject.getString("_id"), jSONObject.getString("firstName"), jSONObject.getString("lastName"), jSONObject.getString("image"), jSONObject.getString("NFC"), jSONObject.getString("NIP")));
}
if (jSONObject.isNull("image") && jSONObject.getString("image").equalsIgnoreCase("")) {
this.arrayListEDM.add(new EmployeeDataModel(jSONObject.getString("_id"), jSONObject.getString("firstName"), jSONObject.getString("lastName"), "", "", jSONObject.getString("NIP")));
}
this.arrayListEDM.add(new EmployeeDataModel(jSONObject.getString("_id"), jSONObject.getString("firstName"), jSONObject.getString("lastName"), jSONObject.getString("image"), "", jSONObject.getString("NIP")));
}
}
Collections.sort(this.arrayListEDM, new Comparator() {
@Override
public final int compare(Object obj, Object obj2) {
int compareToIgnoreCase;
compareToIgnoreCase = (r1.getEmployeeFirstName() + " " + ((EmployeeDataModel) obj).getEmployeeLastName()).compareToIgnoreCase(r2.getEmployeeFirstName() + " " + ((EmployeeDataModel) obj2).getEmployeeLastName());
return compareToIgnoreCase;
}
});
ListViewAdapterEmployee listViewAdapterEmployee = new ListViewAdapterEmployee(getApplicationContext(), this.arrayListEDM);
this.listViewAdapterEmployee = listViewAdapterEmployee;
this.listViewSearch.setAdapter((ListAdapter) listViewAdapterEmployee);
return;
}
showSnackBar(getResources().getString(R.string.noempoyeeexist));
return;
} catch (JSONException e2) {
e2.printStackTrace();
return;
}
}
showSnackBar(getResources().getString(R.string.noempoyeeexist));
}
protected void clearOrganizationCredentials() {
SharedPreferences.Editor edit = getSharedPreferences("organizationCredentials", 0).edit();
edit.clear();
edit.apply();
}
public JSONObject getOrganizationCredentials() {
try {
return new JSONObject(getSharedPreferences("organizationCredentials", 0).getString("userCredentials", null));
} catch (JSONException e) {
e.printStackTrace();
return null;
}
}
public void setupToolbar() {
setSupportActionBar(this.toolbar);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle("");
this.toolbarTitle.setText(getResources().getString(R.string.allemployeestitle));
}
public void setupDrawerToggle() {
new ActionBarDrawerToggle(this, this.drawerLayout, this.toolbar, R.string.open_drawer, R.string.close_drawer).syncState();
}
protected void onResume() {
super.onResume();
NfcAdapter nfcAdapter = this.mNfcAdapter;
if (nfcAdapter != null && nfcAdapter.isEnabled()) {
setupForegroundDispatch(this, this, this.mNfcAdapter);
}
if (isNetworkAvailable()) {
new GetAllEmployeeNew().execute(new String[0]);
} else {
updateActivity();
}
}
protected void onPause() {
NfcAdapter nfcAdapter = this.mNfcAdapter;
if (nfcAdapter != null && nfcAdapter.isEnabled()) {
stopForegroundDispatch(this, this.mNfcAdapter);
}
super.onPause();
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.harvestmenu, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem menuItem) {
int itemId = menuItem.getItemId();
if (itemId == 2131362006) {
MyApplication.getInstance().setLocale("en");
this.english.setEnabled(false);
this.french.setEnabled(true);
this.spanish.setEnabled(true);
startActivity(getIntent());
overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
finish();
return true;
}
if (itemId == 2131362009) {
MyApplication.getInstance().setLocale("es");
this.spanish.setEnabled(false);
this.english.setEnabled(true);
this.french.setEnabled(true);
startActivity(getIntent());
overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
finish();
return true;
}
if (itemId == 2131362032) {
MyApplication.getInstance().setLocale("fr");
this.french.setEnabled(false);
this.english.setEnabled(true);
this.spanish.setEnabled(true);
startActivity(getIntent());
overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
finish();
return true;
}
return super.onOptionsItemSelected(menuItem);
}
public boolean onPrepareOptionsMenu(Menu menu) {
this.french = menu.findItem(R.id.francais);
this.spanish = menu.findItem(R.id.espanol);
this.english = menu.findItem(R.id.english);
if (Locale.getDefault().getLanguage().equalsIgnoreCase("en")) {
this.english.setEnabled(false);
this.french.setEnabled(true);
this.spanish.setEnabled(true);
} else if (Locale.getDefault().getLanguage().equalsIgnoreCase("fr")) {
this.french.setEnabled(false);
this.english.setEnabled(true);
this.spanish.setEnabled(true);
} else if (Locale.getDefault().getLanguage().equalsIgnoreCase("es")) {
this.spanish.setEnabled(false);
this.english.setEnabled(true);
this.french.setEnabled(true);
}
return true;
}
public void showDialog() {
try {
if (this.pDialog.isShowing()) {
return;
}
this.progressBar.setVisibility(0);
this.pDialog.show();
} catch (Exception e) {
e.printStackTrace();
}
}
public void hideDialog() {
try {
if (!this.pDialog.isShowing() || this.pDialog == null) {
return;
}
this.progressBar.setVisibility(4);
this.pDialog.dismiss();
} catch (Exception e) {
e.printStackTrace();
}
}
private boolean isNetworkAvailable() {
NetworkInfo activeNetworkInfo = ((ConnectivityManager) getSystemService("connectivity")).getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
public String convertStreamToString(InputStream inputStream) {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder sb = new StringBuilder();
while (true) {
try {
try {
try {
String readLine = bufferedReader.readLine();
if (readLine == null) {
break;
}
sb.append(readLine);
sb.append('\n');
} catch (IOException e) {
e.printStackTrace();
inputStream.close();
}
} catch (Throwable th) {
try {
inputStream.close();
} catch (IOException e2) {
e2.printStackTrace();
}
throw th;
}
} catch (IOException e3) {
e3.printStackTrace();
}
}
inputStream.close();
return sb.toString();
}
@Override
public void onTagDiscovered(Tag tag) {
new NdefReaderTask().execute(tag);
}
private static class NdefReaderTask extends AsyncTask<Tag, Void, String> {
@Override
public void onPostExecute(String str) {
}
private NdefReaderTask() {
}
@Override
public String doInBackground(Tag... tagArr) {
Ndef ndef = Ndef.get(tagArr[0]);
if (ndef == null) {
return null;
}
NdefRecord[] records = ndef.getCachedNdefMessage().getRecords();
int length = records.length;
for (int i = 0; i < length; i++) {
NdefRecord ndefRecord = records[i];
if (ndefRecord.getTnf() == 1 && Arrays.equals(ndefRecord.getType(), NdefRecord.RTD_TEXT)) {
try {
return readText(ndefRecord);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}
return null;
}
private String readText(NdefRecord ndefRecord) throws UnsupportedEncodingException {
byte[] payload = ndefRecord.getPayload();
byte b = payload[0];
return new String(payload, (b & 51) + 1, (payload.length - r0) - 1, (b & ByteCompanionObject.MIN_VALUE) == 0 ? XmpWriter.UTF8 : XmpWriter.UTF16);
}
}
class DrawerItemClickListener implements AdapterView.OnItemClickListener {
private DrawerItemClickListener() {
}
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
selectItem(i);
}
private void selectItem(int i) {
if (i == 1) {
AllEmployeesActivity.this.startActivity(new Intent(AllEmployeesActivity.this.getApplicationContext(), (Class<?>) HarvestActivity.class));
AllEmployeesActivity.this.finish();
AllEmployeesActivity.this.overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
return;
}
if (i == 2) {
AllEmployeesActivity.this.drawerLayout.closeDrawers();
return;
}
if (i != 3) {
if (i == 4) {
AllEmployeesActivity.this.drawerLayout.closeDrawers();
if (AllEmployeesActivity.this.drawerItem.get(3).name.equals(AllEmployeesActivity.this.getResources().getString(R.string.scanner))) {
AllEmployeesActivity.this.startActivity(new Intent((Context) AllEmployeesActivity.this, (Class<?>) QrCodeScannerActivity.class));
return;
}
return;
}
return;
}
AllEmployeesActivity.this.drawerLayout.closeDrawers();
final Dialog dialog = new Dialog(AllEmployeesActivity.this);
dialog.setCanceledOnTouchOutside(false);
dialog.requestWindowFeature(1);
dialog.setContentView(R.layout.fragment_logout);
dialog.setTitle("");
TextView textView = (TextView) dialog.findViewById(R.id.donButtonDialog);
TextView textView2 = (TextView) dialog.findViewById(R.id.cancelButtonDialog);
final EditText editText = (EditText) dialog.findViewById(R.id.orgCode);
final EditText editText2 = (EditText) dialog.findViewById(R.id.orgkey);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
AllEmployeesActivity.DrawerItemClickListener.this.m10xecbab47(editText, editText2, dialog, view);
}
});
textView2.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
dialog.dismiss();
}
});
dialog.show();
}
void m10xecbab47(EditText editText, EditText editText2, final Dialog dialog, View view) {
if (editText.getText().toString().trim().isEmpty()) {
editText.setError("Organization code required");
return;
}
if (!editText2.getText().toString().trim().isEmpty()) {
JSONObject organizationCredentials = AllEmployeesActivity.this.getOrganizationCredentials();
try {
if (editText.getText().toString().trim().equalsIgnoreCase(organizationCredentials.getString("code")) && editText2.getText().toString().trim().equalsIgnoreCase(organizationCredentials.getString("key"))) {
AllEmployeesActivity.this.setMessage.setText(AllEmployeesActivity.this.getResources().getString(R.string.loggingout));
AllEmployeesActivity.this.showDialog();
new Handler().postDelayed(new Runnable() {
@Override
public final void run() {
AllEmployeesActivity.DrawerItemClickListener.this.m9x330a2f86(dialog);
}
}, 3000L);
} else {
Toast.makeText(AllEmployeesActivity.this.getApplicationContext(), AllEmployeesActivity.this.getResources().getString(R.string.notloginwiththisaccount), 1).show();
}
return;
} catch (JSONException unused) {
Toast.makeText(AllEmployeesActivity.this.getApplicationContext(), AllEmployeesActivity.this.getResources().getString(R.string.somethingwentwrong), 1).show();
return;
}
}
editText2.setError("Organization key required");
}
void m9x330a2f86(Dialog dialog) {
dialog.dismiss();
AllEmployeesActivity.this.hideDialog();
MyApplication.getInstance().logout();
AllEmployeesActivity.this.clearOrganizationCredentials();
}
}
public class GetAllEmployee extends AsyncTask<String, Void, String> {
String organizationId = "";
public GetAllEmployee() {
}
@Override
protected void onPreExecute() {
AllEmployeesActivity.this.setMessage.setText(AllEmployeesActivity.this.getResources().getString(R.string.refreshingdata));
AllEmployeesActivity.this.showDialog();
try {
this.organizationId = new JSONObject(MyApplication.getInstance().getPrefManager().getOrganizationEmployee().getOrganizationInfo()).getString("_id");
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public String doInBackground(String... strArr) {
DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
HttpConnectionParams.setConnectionTimeout(defaultHttpClient.getParams(), 1000);
InputStream inputStream = null;
try {
HttpResponse execute = defaultHttpClient.execute(new HttpGet(EndPoints.GET_ALL_EMPLOYEES_OLD + this.organizationId));
if (execute != null) {
inputStream = execute.getEntity().getContent();
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e2) {
e2.printStackTrace();
} catch (IOException e3) {
e3.printStackTrace();
}
return inputStream != null ? AllEmployeesActivity.this.convertStreamToString(inputStream) : "";
}
@Override
public void onPostExecute(String str) {
AllEmployeesActivity.this.hideDialog();
if (!str.equals("")) {
try {
MyApplication.getInstance().getPrefManager().storeEmployees(this.organizationId, new JSONObject(str).getJSONArray("employee").toString());
AllEmployeesActivity.this.updateActivity();
return;
} catch (JSONException unused) {
AllEmployeesActivity allEmployeesActivity = AllEmployeesActivity.this;
allEmployeesActivity.showSnackBar(allEmployeesActivity.getResources().getString(R.string.somethingwentwrong));
return;
}
}
if (MyApplication.getInstance().getPrefManager().getEmployees(this.organizationId) != null) {
AllEmployeesActivity.this.updateActivity();
} else {
AllEmployeesActivity allEmployeesActivity2 = AllEmployeesActivity.this;
allEmployeesActivity2.showSnackBar(allEmployeesActivity2.getResources().getString(R.string.internetconnectionproblem));
}
}
}
public class GetAllEmployeeNew extends AsyncTask<String, Void, String> {
String organizationId = "";
public GetAllEmployeeNew() {
}
@Override
protected void onPreExecute() {
AllEmployeesActivity.this.setMessage.setText(AllEmployeesActivity.this.getResources().getString(R.string.refreshingdata));
AllEmployeesActivity.this.showDialog();
try {
this.organizationId = new JSONObject(MyApplication.getInstance().getPrefManager().getOrganizationEmployee().getOrganizationInfo()).getString("_id");
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public String doInBackground(String... strArr) {
DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
HttpConnectionParams.setConnectionTimeout(defaultHttpClient.getParams(), 1000);
InputStream inputStream = null;
try {
HttpResponse execute = defaultHttpClient.execute(new HttpGet(EndPoints.GET_ALL_EMPLOYEES + this.organizationId + "&date=" + AllEmployeesActivity.this.date));
if (execute != null) {
inputStream = execute.getEntity().getContent();
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e2) {
e2.printStackTrace();
} catch (IOException e3) {
e3.printStackTrace();
}
return inputStream != null ? AllEmployeesActivity.this.convertStreamToString(inputStream) : "";
}
@Override
public void onPostExecute(String str) {
AllEmployeesActivity.this.hideDialog();
if (!str.equals("")) {
try {
MyApplication.getInstance().getPrefManager().storeEmployees(this.organizationId, new JSONObject(str).getJSONObject("data").getJSONArray("activeEmployees").toString());
AllEmployeesActivity.this.updateActivity();
return;
} catch (JSONException unused) {
AllEmployeesActivity allEmployeesActivity = AllEmployeesActivity.this;
allEmployeesActivity.showSnackBar(allEmployeesActivity.getResources().getString(R.string.somethingwentwrong));
return;
}
}
if (MyApplication.getInstance().getPrefManager().getEmployees(this.organizationId) != null) {
AllEmployeesActivity.this.updateActivity();
} else {
AllEmployeesActivity allEmployeesActivity2 = AllEmployeesActivity.this;
allEmployeesActivity2.showSnackBar(allEmployeesActivity2.getResources().getString(R.string.internetconnectionproblem));
}
}
}
}