正在查看: St.John's v1.0.9 应用的 SubmitFeeConcernActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 SubmitFeeConcernActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mcb.stjohnsemschool.activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import com.mcb.stjohnsemschool.fragment.FileUploadFragmentDialog;
import com.mcb.stjohnsemschool.interfaces.OnImageCapturedInterface;
import com.mcb.stjohnsemschool.model.FinanceConcernedDocumentsModel;
import com.mcb.stjohnsemschool.model.ParentConcernCategoriesModelClass;
import com.mcb.stjohnsemschool.model.SavingResponseModel;
import com.mcb.stjohnsemschool.services.ApiClient;
import com.mcb.stjohnsemschool.services.ApiInterface;
import com.mcb.stjohnsemschool.utils.Constants;
import com.mcb.stjohnsemschool.utils.FileUtils;
import com.mcb.stjohnsemschool.utils.TransparentProgressDialog;
import com.mcb.stjohnsemschool.utils.Utility;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class SubmitFeeConcernActivity extends AppCompatActivity implements View.OnClickListener, OnImageCapturedInterface {
private SubmitFeeConcernActivity activity;
private String addressStr;
private String branchId;
private int concernCategoryId;
private String concernTypeCategory;
private int concernTypeCategoryId;
private String detailsOfConcern;
private ArrayList<FinanceConcernedDocumentsModel> documentsList;
private EditText mAddressEt;
private TextView mAttachFile;
private TextView mAttachedFileName;
private LinearLayout mAttachmentsMainLl;
private LinearLayout mChangeMonthlyFeePlanLl;
private ImageView mCloseIv;
private EditText mCompanyNameEt;
private Spinner mConcernCategories;
private EditText mContactNumberEt;
private EditText mDetailsOfConcern;
private LinearLayout mDocumentsLl;
private EditText mEmailEt;
private EditText mFatherBasicSalEt;
private EditText mFatherDeductionsEt;
private EditText mFatherGrossEt;
private EditText mFatherHraEt;
private EditText mFatherOccupationEt;
private EditText mFatherOtherAllowEt;
private LinearLayout mGeneralConcernLl;
private EditText mMotherBasicSalEt;
private EditText mMotherDeductionsEt;
private EditText mMotherGrossEt;
private EditText mMotherHraEt;
private EditText mMotherOccupationEt;
private EditText mMotherOtherAllowEt;
private CheckBox mNotifyUser;
private TransparentProgressDialog mProgressbar;
private EditText mRemarksEt;
private LinearLayout mRemarksLl;
private String mSelConcernCategoryStr;
private SharedPreferences mSharedPref;
private Button mSubmit;
private OnImageCapturedInterface onImageCaptured;
private String organisationId;
private String studentEnrollmentId;
private String userId;
private String userNameStr = "";
private String academicYearId = "0";
private String filePath = "";
private String mOrganisationName = "";
private String concernCategory = "";
private int notifyUser = 1;
private ArrayList<ParentConcernCategoriesModelClass> concernCategories = new ArrayList<>();
private boolean isFromBrowse = false;
private int fileSelectedPos = -1;
private boolean isGeneralConcern = false;
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_submit_fee_concern);
init();
}
private void init() {
this.onImageCaptured = this;
this.activity = this;
SharedPreferences sharedPreferences = getSharedPreferences("", 0);
this.mSharedPref = sharedPreferences;
this.userId = sharedPreferences.getString("UseridKey", this.userId);
this.studentEnrollmentId = this.mSharedPref.getString("studentEnrollmentIdKey", this.studentEnrollmentId);
this.organisationId = this.mSharedPref.getString("orgnizationIdKey", this.organisationId);
this.branchId = this.mSharedPref.getString("BranchIdKey", this.branchId);
this.academicYearId = this.mSharedPref.getString("academicyearIdKey", this.academicYearId);
this.addressStr = this.mSharedPref.getString("Parent_address", "");
this.mOrganisationName = this.mSharedPref.getString("OrganisationNameKey", this.mOrganisationName);
this.userNameStr = this.mSharedPref.getString("usernamekey", "");
this.mProgressbar = new TransparentProgressDialog(this, R.drawable.spinner_loading_imag);
Bundle extras = getIntent().getExtras();
this.concernTypeCategoryId = extras.getInt("ServiceRequestId");
this.concernTypeCategory = extras.getString("ServiceName");
this.mRemarksLl = (LinearLayout) findViewById(R.id.any_remarks_ll);
this.mGeneralConcernLl = (LinearLayout) findViewById(R.id.general_fee_concern_ll);
this.mChangeMonthlyFeePlanLl = (LinearLayout) findViewById(R.id.change_monthly_fee_plan_ll);
this.mAttachFile = (TextView) findViewById(R.id.txv_attach_file);
this.mAttachedFileName = (TextView) findViewById(R.id.txv_attached_file_name);
this.mNotifyUser = (CheckBox) findViewById(R.id.chk_notify_user);
this.mDetailsOfConcern = (EditText) findViewById(R.id.edt_details_of_concern);
this.mAttachFile.setOnClickListener(this);
this.mAttachedFileName.setVisibility(8);
this.mNotifyUser.setVisibility(8);
this.mDocumentsLl = (LinearLayout) findViewById(R.id.documents_ll);
this.mRemarksLl.setVisibility(8);
this.mGeneralConcernLl.setVisibility(8);
this.mChangeMonthlyFeePlanLl.setVisibility(8);
this.mAttachmentsMainLl = (LinearLayout) findViewById(R.id.attachments_main_ll);
this.mFatherOccupationEt = (EditText) findViewById(R.id.father_occupation_et);
this.mMotherOccupationEt = (EditText) findViewById(R.id.mother_occupation_et);
this.mCompanyNameEt = (EditText) findViewById(R.id.company_name_et);
this.mContactNumberEt = (EditText) findViewById(R.id.contact_number_et);
this.mEmailEt = (EditText) findViewById(R.id.company_email_et);
this.mAddressEt = (EditText) findViewById(R.id.address_et);
this.mFatherGrossEt = (EditText) findViewById(R.id.father_gross_salary_et);
this.mMotherGrossEt = (EditText) findViewById(R.id.mother_gross_salary_et);
this.mFatherBasicSalEt = (EditText) findViewById(R.id.father_basic_salary_et);
this.mMotherBasicSalEt = (EditText) findViewById(R.id.mother_basic_salary_et);
this.mFatherHraEt = (EditText) findViewById(R.id.father_hra_et);
this.mMotherHraEt = (EditText) findViewById(R.id.mother_hra_et);
this.mFatherOtherAllowEt = (EditText) findViewById(R.id.father_other_allowance_et);
this.mMotherOtherAllowEt = (EditText) findViewById(R.id.mother_other_allowance_et);
this.mFatherDeductionsEt = (EditText) findViewById(R.id.father_deductions_et);
this.mMotherDeductionsEt = (EditText) findViewById(R.id.mother_deductions_et);
this.mRemarksEt = (EditText) findViewById(R.id.remarks_any_et);
ImageView imageView = (ImageView) findViewById(R.id.close_iv);
this.mCloseIv = imageView;
imageView.setOnClickListener(this);
this.mSubmit = (Button) findViewById(R.id.btn_submit);
this.mConcernCategories = (Spinner) findViewById(R.id.spn_concern_categories);
this.mSubmit.setOnClickListener(this);
this.mConcernCategories.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
SubmitFeeConcernActivity submitFeeConcernActivity = SubmitFeeConcernActivity.this;
submitFeeConcernActivity.concernCategoryId = ((ParentConcernCategoriesModelClass) submitFeeConcernActivity.concernCategories.get(i)).getServiceRequestId();
SubmitFeeConcernActivity submitFeeConcernActivity2 = SubmitFeeConcernActivity.this;
submitFeeConcernActivity2.concernCategory = ((ParentConcernCategoriesModelClass) submitFeeConcernActivity2.concernCategories.get(i)).getServiceName();
SubmitFeeConcernActivity submitFeeConcernActivity3 = SubmitFeeConcernActivity.this;
submitFeeConcernActivity3.mSelConcernCategoryStr = submitFeeConcernActivity3.concernCategory.toLowerCase();
SubmitFeeConcernActivity submitFeeConcernActivity4 = SubmitFeeConcernActivity.this;
submitFeeConcernActivity4.updateUI(submitFeeConcernActivity4.mSelConcernCategoryStr);
}
});
getServiceCategories();
}
public void updateUI(String str) {
if (str.equalsIgnoreCase("change monthly fee plan")) {
this.isGeneralConcern = false;
this.mRemarksLl.setVisibility(0);
this.mGeneralConcernLl.setVisibility(8);
this.mChangeMonthlyFeePlanLl.setVisibility(0);
this.mSubmit.setVisibility(0);
getFinanceConcernAssignedDocuments();
return;
}
if (this.concernCategoryId == 0) {
this.isGeneralConcern = false;
this.mRemarksLl.setVisibility(8);
this.mGeneralConcernLl.setVisibility(8);
this.mChangeMonthlyFeePlanLl.setVisibility(8);
this.mSubmit.setVisibility(4);
return;
}
this.isGeneralConcern = true;
this.mSubmit.setVisibility(0);
this.mRemarksLl.setVisibility(8);
this.mGeneralConcernLl.setVisibility(0);
this.mChangeMonthlyFeePlanLl.setVisibility(8);
}
private void getFinanceConcernAssignedDocuments() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(getApplicationContext()).create(ApiInterface.class)).getFinanceConcernAssignedDocuments(Integer.parseInt(this.branchId), Integer.parseInt(this.academicYearId), Utility.getSchoolApiKey(getApplicationContext())).enqueue(new Callback<ArrayList<FinanceConcernedDocumentsModel>>() {
public void onResponse(Call<ArrayList<FinanceConcernedDocumentsModel>> call, Response<ArrayList<FinanceConcernedDocumentsModel>> response) {
if (SubmitFeeConcernActivity.this.mProgressbar != null && SubmitFeeConcernActivity.this.mProgressbar.isShowing()) {
SubmitFeeConcernActivity.this.mProgressbar.dismiss();
}
if (response != null && response.body() != null) {
if (!response.isSuccessful()) {
SubmitFeeConcernActivity.this.mDocumentsLl.setVisibility(8);
return;
}
SubmitFeeConcernActivity.this.documentsList = (ArrayList) response.body();
SubmitFeeConcernActivity submitFeeConcernActivity = SubmitFeeConcernActivity.this;
submitFeeConcernActivity.addDocsToView(submitFeeConcernActivity.documentsList);
SubmitFeeConcernActivity.this.mDocumentsLl.setVisibility(0);
return;
}
Utility.showAlertDialog(SubmitFeeConcernActivity.this);
}
public void onFailure(Call<ArrayList<FinanceConcernedDocumentsModel>> call, Throwable th) {
if (SubmitFeeConcernActivity.this.mProgressbar != null && SubmitFeeConcernActivity.this.mProgressbar.isShowing()) {
SubmitFeeConcernActivity.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(SubmitFeeConcernActivity.this);
}
});
}
public void addDocsToView(ArrayList<FinanceConcernedDocumentsModel> arrayList) {
this.fileSelectedPos = -1;
this.mAttachmentsMainLl.removeAllViews();
LayoutInflater layoutInflater = (LayoutInflater) getApplicationContext().getSystemService("layout_inflater");
if (arrayList.size() > 0) {
for (int i = 0; i < arrayList.size(); i++) {
RelativeLayout relativeLayout = (RelativeLayout) layoutInflater.inflate(R.layout.file_chooser_layout, (ViewGroup) null);
TextView textView = (TextView) relativeLayout.findViewById(R.id.doc_title_tv);
TextView textView2 = (TextView) relativeLayout.findViewById(R.id.star_tv);
TextView textView3 = (TextView) relativeLayout.findViewById(R.id.choose_tv);
TextView textView4 = (TextView) relativeLayout.findViewById(R.id.selected_doc_name_tv);
textView4.setVisibility(4);
String selectedFileName = arrayList.get(i).getSelectedFileName();
if (arrayList.get(i).isFileSelected() && selectedFileName != null && !selectedFileName.isEmpty()) {
textView4.setText(selectedFileName);
textView4.setVisibility(0);
} else {
textView4.setVisibility(4);
}
textView.setText("" + arrayList.get(i).getDocumentDisplayName());
if (arrayList.get(i).getIsMandatory().booleanValue()) {
textView2.setVisibility(0);
} else {
textView2.setVisibility(4);
}
textView3.setTag(Integer.valueOf(i));
textView3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SubmitFeeConcernActivity.this.fileSelectedPos = ((Integer) view.getTag()).intValue();
SubmitFeeConcernActivity.this.isFromBrowse = false;
FileUploadFragmentDialog fileUploadFragmentDialog = new FileUploadFragmentDialog(new ArrayList(), false, SubmitFeeConcernActivity.this.onImageCaptured);
fileUploadFragmentDialog.show(SubmitFeeConcernActivity.this.getSupportFragmentManager(), fileUploadFragmentDialog.getTag());
}
});
this.mAttachmentsMainLl.addView(relativeLayout);
}
}
}
private int docsValidate() {
ArrayList<FinanceConcernedDocumentsModel> arrayList = this.documentsList;
if (arrayList != null && arrayList.size() > 0) {
for (int i = 0; i < this.documentsList.size(); i++) {
FinanceConcernedDocumentsModel financeConcernedDocumentsModel = this.documentsList.get(i);
if (financeConcernedDocumentsModel.getIsMandatory().booleanValue() && !financeConcernedDocumentsModel.isFileSelected()) {
return i;
}
}
}
return -1;
}
private void getServiceCategories() {
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(getApplicationContext()).create(ApiInterface.class)).getServiceRequestsNewOther(Integer.parseInt(this.organisationId), this.concernTypeCategoryId, Integer.parseInt(this.academicYearId), Integer.parseInt(this.studentEnrollmentId), Utility.getSchoolApiKey(this)).enqueue(new Callback<ArrayList<ParentConcernCategoriesModelClass>>() {
public void onResponse(Call<ArrayList<ParentConcernCategoriesModelClass>> call, Response<ArrayList<ParentConcernCategoriesModelClass>> response) {
if (SubmitFeeConcernActivity.this.mProgressbar != null && SubmitFeeConcernActivity.this.mProgressbar.isShowing()) {
SubmitFeeConcernActivity.this.mProgressbar.dismiss();
}
if (response != null && response.body() != null) {
SubmitFeeConcernActivity.this.concernCategories.clear();
SubmitFeeConcernActivity.this.concernCategories = (ArrayList) response.body();
ParentConcernCategoriesModelClass parentConcernCategoriesModelClass = new ParentConcernCategoriesModelClass();
parentConcernCategoriesModelClass.setServiceName("-Select-");
parentConcernCategoriesModelClass.setServiceRequestId(0);
SubmitFeeConcernActivity.this.concernCategories.add(0, parentConcernCategoriesModelClass);
SubmitFeeConcernActivity.this.mConcernCategories.setAdapter((SpinnerAdapter) new ArrayAdapter(SubmitFeeConcernActivity.this.getApplicationContext(), R.layout.customlayout, SubmitFeeConcernActivity.this.concernCategories));
return;
}
Utility.showAlertDialog(SubmitFeeConcernActivity.this);
}
public void onFailure(Call<ArrayList<ParentConcernCategoriesModelClass>> call, Throwable th) {
if (SubmitFeeConcernActivity.this.mProgressbar != null && SubmitFeeConcernActivity.this.mProgressbar.isShowing()) {
SubmitFeeConcernActivity.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(SubmitFeeConcernActivity.this);
}
});
return;
}
Toast.makeText(getApplicationContext(), "Check your Network Connection", 0).show();
}
public String removeLastChar(String str) {
return (str == null || str.length() == 0) ? str : str.substring(0, str.length() - 1);
}
private void saveMonthlyFeePlanConcern() {
String str;
String str2;
String str3;
String str4;
String str5;
String str6 = "" + this.mFatherOccupationEt.getText().toString().trim();
String str7 = "" + this.mMotherOccupationEt.getText().toString().trim();
String str8 = "" + this.mCompanyNameEt.getText().toString().trim();
String str9 = "" + this.mContactNumberEt.getText().toString().trim();
String str10 = "" + this.mEmailEt.getText().toString().trim();
String str11 = "" + this.mAddressEt.getText().toString().trim();
String str12 = "" + this.mFatherGrossEt.getText().toString().trim();
String str13 = "" + this.mMotherGrossEt.getText().toString().trim();
String str14 = "" + this.mFatherBasicSalEt.getText().toString().trim();
String str15 = "" + this.mMotherBasicSalEt.getText().toString().trim();
String str16 = "" + this.mFatherHraEt.getText().toString().trim();
String str17 = "" + this.mMotherHraEt.getText().toString().trim();
String str18 = "" + this.mFatherOtherAllowEt.getText().toString().trim();
String str19 = "" + this.mMotherOtherAllowEt.getText().toString().trim();
String str20 = "" + this.mFatherDeductionsEt.getText().toString().trim();
String str21 = "" + this.mMotherDeductionsEt.getText().toString().trim();
String str22 = "" + this.mRemarksEt.getText().toString().trim();
ArrayList<FinanceConcernedDocumentsModel> arrayList = this.documentsList;
if (arrayList == null || arrayList.isEmpty()) {
str = str13;
str2 = str21;
str3 = str20;
str4 = "";
} else {
str = str13;
str2 = str21;
str4 = "";
int i = 0;
while (i < this.documentsList.size()) {
FinanceConcernedDocumentsModel financeConcernedDocumentsModel = this.documentsList.get(i);
String selectedFileCDNPath = financeConcernedDocumentsModel.getSelectedFileCDNPath();
if (selectedFileCDNPath == null || selectedFileCDNPath.isEmpty()) {
str5 = str20;
} else {
str5 = str20;
str4 = str4 + financeConcernedDocumentsModel.getDocumentTypeID() + "_" + financeConcernedDocumentsModel.getSelectedFileCDNPath() + ",";
}
i++;
str20 = str5;
}
str3 = str20;
}
HashMap hashMap = new HashMap();
hashMap.put("StudentEnrollmentID", this.studentEnrollmentId);
hashMap.put("BrancheId", this.branchId);
hashMap.put("AcademicYearID", this.academicYearId);
hashMap.put("OrganisationID", String.valueOf(25));
hashMap.put("OrganisationName", this.mOrganisationName);
hashMap.put("User", this.userId);
hashMap.put("UserName", this.userNameStr);
hashMap.put("Message", str22);
hashMap.put("ServiceRequestID", String.valueOf(this.concernCategoryId));
hashMap.put("ServiceReqText", this.concernCategory);
hashMap.put("NotifyUsers", String.valueOf(1));
hashMap.put("FatherOccupation", str6);
hashMap.put("MotherOccupation", str7);
hashMap.put("CompanyName", str8);
hashMap.put("ContactNo", str9);
hashMap.put("EmailID", str10);
hashMap.put("Address", str11);
hashMap.put("FatherGross", str12);
hashMap.put("FatherBasic", str14);
hashMap.put("FatherHRA", str16);
hashMap.put("FatherOtherAllowances", str18);
hashMap.put("FatherDeduction", str3);
hashMap.put("MotherGross", str);
hashMap.put("MotherBasic", str15);
hashMap.put("MotherHRA", str17);
hashMap.put("MotherAllowances", str19);
hashMap.put("MotherDeduction", str2);
hashMap.put("DocumentTypeID", removeLastChar(str4));
hashMap.put("apikey", Utility.getSchoolApiKey(getApplicationContext()));
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(getApplicationContext()).create(ApiInterface.class)).saveMonthlyFeePlanConcern(hashMap).enqueue(new Callback<SavingResponseModel>() {
public void onResponse(Call<SavingResponseModel> call, Response<SavingResponseModel> response) {
if (SubmitFeeConcernActivity.this.mProgressbar != null && SubmitFeeConcernActivity.this.mProgressbar.isShowing()) {
SubmitFeeConcernActivity.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(SubmitFeeConcernActivity.this.activity);
return;
}
SavingResponseModel savingResponseModel = (SavingResponseModel) response.body();
final int intValue = savingResponseModel.getStatus().intValue();
String message = savingResponseModel.getMessage();
AlertDialog.Builder builder = new AlertDialog.Builder(SubmitFeeConcernActivity.this);
builder.setMessage(message).setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i2) {
dialogInterface.dismiss();
if (intValue == 1) {
SubmitFeeConcernActivity.this.finish();
}
}
}).setCancelable(false);
builder.create().show();
}
public void onFailure(Call<SavingResponseModel> call, Throwable th) {
if (SubmitFeeConcernActivity.this.mProgressbar != null && SubmitFeeConcernActivity.this.mProgressbar.isShowing()) {
SubmitFeeConcernActivity.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(SubmitFeeConcernActivity.this.activity);
}
});
}
@Override
public void onClick(View view) {
Constants.hideKeyboard(this.activity);
if (view == this.mAttachFile) {
FileUploadFragmentDialog fileUploadFragmentDialog = new FileUploadFragmentDialog(new ArrayList(), false, this.onImageCaptured);
fileUploadFragmentDialog.show(getSupportFragmentManager(), fileUploadFragmentDialog.getTag());
return;
}
if (view == this.mCloseIv) {
finish();
return;
}
if (view == this.mSubmit) {
this.detailsOfConcern = this.mDetailsOfConcern.getText().toString().trim();
this.notifyUser = 1;
if (this.concernCategoryId > 0) {
saveConcerns();
} else {
Toast.makeText(getApplicationContext(), "Please select concern type", 0).show();
}
}
}
private void saveConcerns() {
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
if (this.mSelConcernCategoryStr.equalsIgnoreCase("change monthly fee plan")) {
int docsValidate = docsValidate();
if (docsValidate == -1) {
saveMonthlyFeePlanConcern();
return;
}
String documentDisplayName = this.documentsList.get(docsValidate).getDocumentDisplayName();
Toast.makeText(getApplicationContext(), "Please Upload " + documentDisplayName, 0).show();
return;
}
if (this.detailsOfConcern.length() > 0) {
submitServiceTicket();
return;
} else {
Toast.makeText(getApplicationContext(), "Please enter details of concern", 0).show();
return;
}
}
Toast.makeText(getApplicationContext(), "Check your Network Connection", 0).show();
}
public void onFileCaptured(ArrayList<String> arrayList) {
if (arrayList == null || arrayList.size() <= 0) {
return;
}
if (this.isGeneralConcern) {
String str = arrayList.get(0);
this.filePath = str;
if (str == null || str.length() <= 0) {
return;
}
getFileNameByPath();
return;
}
uploadFileToCDN(arrayList.get(0));
}
private void submitServiceTicket() {
MultipartBody.Part part;
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
RequestBody create = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(this.userId));
RequestBody create2 = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(this.studentEnrollmentId));
RequestBody create3 = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(this.organisationId));
RequestBody create4 = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(this.branchId));
RequestBody create5 = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(this.concernCategoryId));
RequestBody create6 = RequestBody.create(MediaType.parse("text/plain"), this.concernCategory);
RequestBody create7 = RequestBody.create(MediaType.parse("text/plain"), this.detailsOfConcern);
RequestBody create8 = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(this.notifyUser));
RequestBody create9 = RequestBody.create(MediaType.parse("text/plain"), Utility.getSchoolApiKey(getApplicationContext()));
String str = this.filePath;
if (str == null || str.length() <= 0) {
part = null;
} else {
File file = new File(this.filePath);
part = MultipartBody.Part.createFormData("file1", file.getName(), RequestBody.create(MediaType.parse("*/*"), file));
}
((ApiInterface) ApiClient.getClient1(getApplicationContext()).create(ApiInterface.class)).SaveServiceTicket(part, create, create2, create3, create4, create5, create6, create7, create8, create9).enqueue(new Callback<SavingResponseModel>() {
public void onResponse(Call<SavingResponseModel> call, Response<SavingResponseModel> response) {
if (SubmitFeeConcernActivity.this.mProgressbar != null && SubmitFeeConcernActivity.this.mProgressbar.isShowing()) {
SubmitFeeConcernActivity.this.mProgressbar.dismiss();
}
if (response != null && response.body() != null) {
SavingResponseModel savingResponseModel = (SavingResponseModel) response.body();
final int intValue = savingResponseModel.getStatus().intValue();
String message = savingResponseModel.getMessage();
AlertDialog.Builder builder = new AlertDialog.Builder(SubmitFeeConcernActivity.this);
builder.setMessage(message).setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
if (intValue == 1) {
SubmitFeeConcernActivity.this.finish();
}
}
}).setCancelable(false);
builder.create().show();
return;
}
Utility.showAlertDialog(SubmitFeeConcernActivity.this);
}
public void onFailure(Call<SavingResponseModel> call, Throwable th) {
if (SubmitFeeConcernActivity.this.mProgressbar != null && SubmitFeeConcernActivity.this.mProgressbar.isShowing()) {
SubmitFeeConcernActivity.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(SubmitFeeConcernActivity.this);
}
});
}
public void getFileNameByPath() {
try {
String str = this.filePath;
String substring = str.substring(str.lastIndexOf("/") + 1);
String str2 = this.filePath;
String substring2 = str2.substring(str2.lastIndexOf(".") + 1);
this.mAttachedFileName.setText(substring);
if (!substring2.contains("doc") && !substring2.contains("docx") && !substring2.contains("pdf") && !substring2.contains("png") && !substring2.contains("jpg") && !substring2.contains("jpeg") && !substring2.equalsIgnoreCase("heic") && !substring2.equalsIgnoreCase("heif")) {
Toast.makeText(getApplicationContext(), "Only files with extension .doc.docx,.pdf,.jpg,.png, .heic, .heif are allowed", 0).show();
this.mAttachedFileName.setVisibility(8);
}
int parseInt = Integer.parseInt(String.valueOf(new File(this.filePath).length() / 1024));
if (substring == null) {
this.mAttachedFileName.setVisibility(8);
} else if (parseInt > 10240) {
this.mAttachedFileName.setVisibility(8);
this.filePath = "";
Toast.makeText(getApplicationContext(), "File size exceeds allowed limit of 10MB", 0).show();
} else {
this.mAttachedFileName.setVisibility(0);
}
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(), "File not supported!!", 0).show();
}
}
protected void onActivityResult(int i, int i2, Intent intent) {
super.onActivityResult(i, i2, intent);
if (i2 != 100 || intent == null) {
return;
}
if (this.isGeneralConcern) {
ArrayList<String> stringArrayListExtra = intent.getStringArrayListExtra("FilePaths");
if (stringArrayListExtra.size() > 0) {
this.filePath = stringArrayListExtra.get(0);
}
String str = this.filePath;
if (str == null || str.length() <= 0) {
return;
}
getFileNameByPath();
return;
}
ArrayList<String> stringArrayListExtra2 = intent.getStringArrayListExtra("FilePaths");
if (intent.hasExtra("IsFromBrowse")) {
this.isFromBrowse = intent.getBooleanExtra("IsFromBrowse", false);
}
if (stringArrayListExtra2 == null || stringArrayListExtra2.size() <= 0) {
return;
}
uploadFileToCDN(stringArrayListExtra2.get(0));
}
private void uploadFileToCDN(String str) {
if (Integer.parseInt(String.valueOf(new File(str).length() / 1024)) > 10240) {
if (this.isFromBrowse && str != null && str.length() > 0) {
FileUtils.deleteFile(getApplicationContext(), str);
}
Utility.showInfoDialog(this, "File size should not exceed 10 MB");
return;
}
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
uploadFilesToCDNAndGetPath(str);
} else {
Toast.makeText(getApplicationContext(), "Check your Network Connection", 0).show();
}
}
private void uploadFilesToCDNAndGetPath(final String str) {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
if (str != null) {
try {
if (str.length() > 0) {
RequestBody create = RequestBody.create(MediaType.parse("text/plain"), "ParentConcerns");
RequestBody create2 = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(this.organisationId));
RequestBody create3 = RequestBody.create(MediaType.parse("text/plain"), Utility.getSchoolApiKey(getApplicationContext()));
RequestBody create4 = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(this.userId));
ArrayList arrayList = new ArrayList();
final String substring = str.substring(str.lastIndexOf("/") + 1);
File file = new File(str);
arrayList.add(MultipartBody.Part.createFormData("file1", file.getName(), RequestBody.create(MediaType.parse("*/*"), file)));
((ApiInterface) ApiClient.getClient1(getApplicationContext()).create(ApiInterface.class)).SaveFilesToCDNNew(arrayList, create, create2, create4, create3).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
String str2;
if (SubmitFeeConcernActivity.this.mProgressbar != null && SubmitFeeConcernActivity.this.mProgressbar.isShowing()) {
SubmitFeeConcernActivity.this.mProgressbar.dismiss();
}
if (response != null) {
try {
if (response.code() == 200) {
if (response.body() != null) {
if (SubmitFeeConcernActivity.this.isFromBrowse && (str2 = str) != null && str2.length() > 0) {
FileUtils.deleteFile(SubmitFeeConcernActivity.this.getApplicationContext(), str);
}
String[] split = ((String) response.body()).split(",");
if (split != null) {
for (String str3 : split) {
if (SubmitFeeConcernActivity.this.fileSelectedPos != -1 && SubmitFeeConcernActivity.this.documentsList.size() >= SubmitFeeConcernActivity.this.fileSelectedPos) {
((FinanceConcernedDocumentsModel) SubmitFeeConcernActivity.this.documentsList.get(SubmitFeeConcernActivity.this.fileSelectedPos)).setFileSelected(true);
((FinanceConcernedDocumentsModel) SubmitFeeConcernActivity.this.documentsList.get(SubmitFeeConcernActivity.this.fileSelectedPos)).setSelectedFileCDNPath(str3);
((FinanceConcernedDocumentsModel) SubmitFeeConcernActivity.this.documentsList.get(SubmitFeeConcernActivity.this.fileSelectedPos)).setSelectedFileName(substring);
}
}
}
SubmitFeeConcernActivity submitFeeConcernActivity = SubmitFeeConcernActivity.this;
submitFeeConcernActivity.addDocsToView(submitFeeConcernActivity.documentsList);
return;
}
return;
}
} catch (Exception e) {
Toast.makeText(SubmitFeeConcernActivity.this.getApplicationContext(), "Unable to get Server Response,Retry!", 0).show();
e.printStackTrace();
return;
}
}
Toast.makeText(SubmitFeeConcernActivity.this.getApplicationContext(), response.message(), 0).show();
}
public void onFailure(Call<String> call, Throwable th) {
Toast.makeText(SubmitFeeConcernActivity.this.getApplicationContext(), th.getMessage(), 0).show();
if (SubmitFeeConcernActivity.this.mProgressbar != null && SubmitFeeConcernActivity.this.mProgressbar.isShowing()) {
SubmitFeeConcernActivity.this.mProgressbar.dismiss();
}
SubmitFeeConcernActivity.this.finish();
}
});
}
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(), "Unable to get Server Response", 0).show();
TransparentProgressDialog transparentProgressDialog2 = this.mProgressbar;
if (transparentProgressDialog2 == null || !transparentProgressDialog2.isShowing()) {
return;
}
this.mProgressbar.dismiss();
}
}
}
}