正在查看: St.John's v1.0.9 应用的 DesignMateSubscribedCoursePacksFragment.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 DesignMateSubscribedCoursePacksFragment.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mcb.stjohnsemschool.fragment;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.mcb.stjohnsemschool.activity.OnlinePaymentActivity;
import com.mcb.stjohnsemschool.activity.SoapObjectProvider;
import com.mcb.stjohnsemschool.adapter.DesignMateCoursePacksAdapter;
import com.mcb.stjohnsemschool.interfaces.BuyCoursePack;
import com.mcb.stjohnsemschool.model.ApiResponse;
import com.mcb.stjohnsemschool.model.DesignMateCoursePacksModel;
import com.mcb.stjohnsemschool.model.LearningPaymentDetailsResponse;
import com.mcb.stjohnsemschool.services.ApiClient;
import com.mcb.stjohnsemschool.services.ApiInterface;
import com.mcb.stjohnsemschool.utils.Constants;
import com.mcb.stjohnsemschool.utils.TransparentProgressDialog;
import com.mcb.stjohnsemschool.utils.Utility;
import com.microsoft.identity.common.java.eststelemetry.SchemaConstants;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONObject;
import org.ksoap2.serialization.SoapObject;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class DesignMateSubscribedCoursePacksFragment extends Fragment implements BuyCoursePack {
private Activity activity;
private BuyCoursePack buyCoursePack;
private Context context;
private ListView mCoursePacks;
private TextView mNoData;
private TransparentProgressDialog mProgressbar;
private SharedPreferences mSharedPref;
private int masterClassId;
private String studentEnrollmentId = SchemaConstants.Value.FALSE;
private String userId = SchemaConstants.Value.FALSE;
private String academicYearId = SchemaConstants.Value.FALSE;
private String organizationId = SchemaConstants.Value.FALSE;
private String branchId = SchemaConstants.Value.FALSE;
private String dbName = "";
private String enrollmentCode = "";
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
return layoutInflater.inflate(2131558694, viewGroup, false);
}
public void onActivityCreated(Bundle bundle) {
super.onActivityCreated(bundle);
FragmentActivity activity = getActivity();
this.activity = activity;
this.context = activity.getApplicationContext();
this.buyCoursePack = this;
this.mProgressbar = new TransparentProgressDialog(this.activity, 2131231479);
SharedPreferences sharedPreferences = this.context.getSharedPreferences("", 0);
this.mSharedPref = sharedPreferences;
this.studentEnrollmentId = sharedPreferences.getString("studentEnrollmentIdKey", this.studentEnrollmentId);
this.userId = this.mSharedPref.getString("UseridKey", this.userId);
this.academicYearId = this.mSharedPref.getString("academicyearIdKey", this.academicYearId);
this.organizationId = this.mSharedPref.getString("orgnizationIdKey", this.organizationId);
this.branchId = this.mSharedPref.getString("BranchIdKey", this.branchId);
this.enrollmentCode = this.mSharedPref.getString("EnrollmentCode", "");
initializations();
}
private void initializations() {
this.mCoursePacks = (ListView) getView().findViewById(2131362967);
this.mNoData = (TextView) getView().findViewById(2131361901);
this.mCoursePacks.setDividerHeight(0);
this.mCoursePacks.setVisibility(8);
this.mNoData.setVisibility(8);
}
public void onResume() {
super.onResume();
String string = this.context.getSharedPreferences("", 0).getString("usernamekey", "");
Bundle bundle = new Bundle();
bundle.putString(Constants.FIREBASE_KEY_USERNAME, string);
FirebaseAnalytics.getInstance(this.activity).logEvent(Constants.FIREBASE_PAGE_DESIGNMATE_SUBSCRIBED_COURSE_PACKS, bundle);
if (Utility.hasNetworkConnection(this.context)) {
new GetStudentDetailsLearning().execute(new String[0]);
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
public void getCoursePacks() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient().create(ApiInterface.class)).getDesginmateSubscribedCoursePacks(this.masterClassId, Integer.parseInt(this.studentEnrollmentId), this.dbName).enqueue(new Callback<ApiResponse<DesignMateCoursePacksModel>>() {
public void onResponse(Call<ApiResponse<DesignMateCoursePacksModel>> call, Response<ApiResponse<DesignMateCoursePacksModel>> response) {
if (DesignMateSubscribedCoursePacksFragment.this.mProgressbar != null && DesignMateSubscribedCoursePacksFragment.this.mProgressbar.isShowing()) {
DesignMateSubscribedCoursePacksFragment.this.mProgressbar.dismiss();
}
if (response.body() == null) {
Utility.showAlertDialog(DesignMateSubscribedCoursePacksFragment.this.activity);
return;
}
if (((ApiResponse) response.body()).getStatus() != 1) {
DesignMateSubscribedCoursePacksFragment.this.mCoursePacks.setVisibility(8);
DesignMateSubscribedCoursePacksFragment.this.mNoData.setVisibility(0);
return;
}
ArrayList result = ((ApiResponse) response.body()).getResult();
if (result.size() <= 0) {
DesignMateSubscribedCoursePacksFragment.this.mCoursePacks.setVisibility(8);
DesignMateSubscribedCoursePacksFragment.this.mNoData.setVisibility(0);
} else {
DesignMateSubscribedCoursePacksFragment.this.mCoursePacks.setAdapter((ListAdapter) new DesignMateCoursePacksAdapter(DesignMateSubscribedCoursePacksFragment.this.context, result, DesignMateSubscribedCoursePacksFragment.this.buyCoursePack));
DesignMateSubscribedCoursePacksFragment.this.mCoursePacks.setVisibility(0);
DesignMateSubscribedCoursePacksFragment.this.mNoData.setVisibility(8);
}
}
public void onFailure(Call<ApiResponse<DesignMateCoursePacksModel>> call, Throwable th) {
if (DesignMateSubscribedCoursePacksFragment.this.mProgressbar != null && DesignMateSubscribedCoursePacksFragment.this.mProgressbar.isShowing()) {
DesignMateSubscribedCoursePacksFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(DesignMateSubscribedCoursePacksFragment.this.activity);
}
});
}
public class GetStudentDetailsLearning extends AsyncTask<String, String, String> {
SoapObject soapObject;
public GetStudentDetailsLearning() {
}
@Override
protected void onPreExecute() {
if (DesignMateSubscribedCoursePacksFragment.this.mProgressbar.isShowing()) {
return;
}
DesignMateSubscribedCoursePacksFragment.this.mProgressbar.show();
}
@Override
public String doInBackground(String... strArr) {
try {
this.soapObject = SoapObjectProvider.GetStudentDetailsLearning(DesignMateSubscribedCoursePacksFragment.this.context, Integer.parseInt(DesignMateSubscribedCoursePacksFragment.this.studentEnrollmentId), Integer.parseInt(DesignMateSubscribedCoursePacksFragment.this.academicYearId));
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
@Override
public void onPostExecute(String str) {
if (DesignMateSubscribedCoursePacksFragment.this.mProgressbar.isShowing()) {
DesignMateSubscribedCoursePacksFragment.this.mProgressbar.dismiss();
}
SoapObject soapObject = this.soapObject;
if (soapObject == null) {
Utility.showAlertDialog(DesignMateSubscribedCoursePacksFragment.this.activity);
return;
}
try {
if (soapObject.getProperty("GetStudentDetails_LearningResult") == null) {
Utility.showAlertDialog(DesignMateSubscribedCoursePacksFragment.this.activity);
return;
}
JSONArray jSONArray = new JSONArray(this.soapObject.getProperty("GetStudentDetails_LearningResult").toString());
if (jSONArray.length() > 0) {
JSONObject jSONObject = jSONArray.getJSONObject(0);
DesignMateSubscribedCoursePacksFragment.this.masterClassId = jSONObject.getInt("MasterClassID");
DesignMateSubscribedCoursePacksFragment.this.dbName = jSONObject.getString("DBName");
}
if (Utility.hasNetworkConnection(DesignMateSubscribedCoursePacksFragment.this.context)) {
DesignMateSubscribedCoursePacksFragment.this.getCoursePacks();
} else {
Toast.makeText(DesignMateSubscribedCoursePacksFragment.this.context, "Check your Network Connection", 0).show();
}
} catch (Exception e) {
Utility.showAlertDialog(DesignMateSubscribedCoursePacksFragment.this.activity);
e.printStackTrace();
}
}
}
private String getEmailId() {
return this.enrollmentCode + "@myclassboard.com";
}
@Override
public void buyCoursePack(DesignMateCoursePacksModel designMateCoursePacksModel) {
if (Utility.hasNetworkConnection(this.context)) {
saveOnlinePaymentDetailsLearning(designMateCoursePacksModel.getCoursePackId(), designMateCoursePacksModel.getMasterClassId(), designMateCoursePacksModel.getAmount() + designMateCoursePacksModel.getGst());
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void saveOnlinePaymentDetailsLearning(int i, int i2, double d) {
String emailId = getEmailId();
if (emailId != null && emailId.length() > 0) {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient().create(ApiInterface.class)).saveOnlinePaymentDetailsLearning(Integer.parseInt(this.studentEnrollmentId), Integer.parseInt(this.academicYearId), i2, Integer.parseInt(this.branchId), Integer.parseInt(this.organizationId), i, this.dbName, String.valueOf(d), emailId).enqueue(new Callback<LearningPaymentDetailsResponse>() {
public void onResponse(Call<LearningPaymentDetailsResponse> call, Response<LearningPaymentDetailsResponse> response) {
if (DesignMateSubscribedCoursePacksFragment.this.mProgressbar != null && DesignMateSubscribedCoursePacksFragment.this.mProgressbar.isShowing()) {
DesignMateSubscribedCoursePacksFragment.this.mProgressbar.dismiss();
}
if (response.body() == null) {
Utility.showAlertDialog(DesignMateSubscribedCoursePacksFragment.this.activity);
return;
}
if (((LearningPaymentDetailsResponse) response.body()).getStatus() != 1) {
Utility.showAlertDialog(DesignMateSubscribedCoursePacksFragment.this.activity);
return;
}
int result = ((LearningPaymentDetailsResponse) response.body()).getResult();
Intent intent = new Intent(DesignMateSubscribedCoursePacksFragment.this.context, (Class<?>) OnlinePaymentActivity.class);
intent.putExtra("PayOnlineUrl", "http://mcbapi.myclassboard.com/OnlinePayment_Web.aspx?postData=" + result);
DesignMateSubscribedCoursePacksFragment.this.startActivity(intent);
}
public void onFailure(Call<LearningPaymentDetailsResponse> call, Throwable th) {
if (DesignMateSubscribedCoursePacksFragment.this.mProgressbar != null && DesignMateSubscribedCoursePacksFragment.this.mProgressbar.isShowing()) {
DesignMateSubscribedCoursePacksFragment.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(DesignMateSubscribedCoursePacksFragment.this.activity);
}
});
return;
}
Toast.makeText(this.context, "Please add email id", 0).show();
}
}