导航菜单

页面标题

页面副标题

St.John's v1.0.9 - McbLiveWebinorActivity.java 源代码

正在查看: St.John's v1.0.9 应用的 McbLiveWebinorActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.mcb.stjohnsemschool.activity;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.os.Bundle;
import android.text.Html;
import android.util.Base64;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.exoplayer2.C;
import com.mcb.stjohnsemschool.model.SavingResponseModel;
import com.mcb.stjohnsemschool.model.WebinarProgramDataModel;
import com.mcb.stjohnsemschool.services.ApiClient;
import com.mcb.stjohnsemschool.services.ApiInterface;
import com.mcb.stjohnsemschool.utils.TransparentProgressDialog;
import com.mcb.stjohnsemschool.utils.Utility;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class McbLiveWebinorActivity extends AppCompatActivity implements View.OnClickListener {
    private Activity activity;
    private ConnectivityManager conMgr;
    private Context context;
    private WebView mAboutProgramPoints;
    private TextView mCaption;
    private TextView mDateTime;
    private TextView mDesignation;
    private TextView mInfo;
    private TextView mInterested;
    private RelativeLayout mMainRL;
    private TextView mPassword;
    private TransparentProgressDialog mProgressbar;
    private WebView mShortNote;
    private TextView mSpeaker;
    private ImageView mSpeakerImg;
    private TextView mTitle;
    private TextView mUrl;
    private int programId;
    private int registrationStatus;
    private int subscriberId;
    private String mobile = "";
    private String studentName = "";
    private String emailAddress = "";
    private String fatherName = "";
    private String schoolName = "";
    private String url = "";

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_mcb_live_webinor);
        getSupportActionBar().setTitle("MCB Live");
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        this.activity = this;
        this.context = getApplicationContext();
        Bundle extras = getIntent().getExtras();
        this.subscriberId = extras.getInt("SubscriberId");
        this.programId = extras.getInt("ProgramId");
        this.registrationStatus = extras.getInt("RegisterStatus");
        this.mobile = extras.getString("Mobile", "");
        this.studentName = extras.getString("StudentName", "");
        this.emailAddress = extras.getString("EmailAddress", "");
        this.fatherName = extras.getString("FatherName", "");
        this.schoolName = extras.getString("SchoolName", "");
        this.context.getSharedPreferences("", 0);
        initializations();
    }

    private void initializations() {
        this.mProgressbar = new TransparentProgressDialog(this.activity, R.drawable.spinner_loading_imag);
        this.mMainRL = (RelativeLayout) findViewById(R.id.rl_main);
        this.mTitle = (TextView) findViewById(R.id.txv_title);
        this.mCaption = (TextView) findViewById(R.id.txv_caption);
        this.mDateTime = (TextView) findViewById(R.id.txv_date_time);
        this.mInterested = (TextView) findViewById(R.id.txv_interested);
        this.mShortNote = (WebView) findViewById(R.id.web_short_note);
        this.mAboutProgramPoints = (WebView) findViewById(R.id.web_outcome_of_program_points);
        this.mSpeaker = (TextView) findViewById(R.id.txv_speaker);
        this.mDesignation = (TextView) findViewById(R.id.txv_designation);
        this.mInfo = (TextView) findViewById(R.id.txv_info);
        this.mSpeakerImg = (ImageView) findViewById(R.id.img_speaker);
        this.mUrl = (TextView) findViewById(R.id.txv_url);
        this.mPassword = (TextView) findViewById(R.id.txv_password);
        this.mMainRL.setVisibility(8);
        this.mInterested.setOnClickListener(this);
        this.mUrl.setOnClickListener(this);
        int i = this.registrationStatus;
        if (i == 1) {
            this.mInterested.setText("Congratulations!! your seat is confirmed.");
            this.mInterested.setVisibility(0);
        } else if (i == 0) {
            this.mInterested.setText("I am Interested");
            this.mInterested.setPaintFlags(8);
            this.mInterested.setVisibility(0);
        } else {
            this.mInterested.setVisibility(8);
        }
        loadWebinarProgramDetails();
    }

    private void loadWebinarProgramDetails() {
        ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
        this.conMgr = connectivityManager;
        if (connectivityManager.getActiveNetworkInfo() != null && this.conMgr.getActiveNetworkInfo().isAvailable() && this.conMgr.getActiveNetworkInfo().isConnected()) {
            getMcbLiveWebinarProgramData();
        } else {
            Toast.makeText(this.context, "Check your Network Connection", 0).show();
        }
    }

    private void getMcbLiveWebinarProgramData() {
        TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
        if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
            this.mProgressbar.show();
        }
        ((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).GetWebinarProgramData(this.programId, Utility.getSchoolApiKey(this.context)).enqueue(new Callback<ArrayList<WebinarProgramDataModel>>() {
            public void onResponse(Call<ArrayList<WebinarProgramDataModel>> call, Response<ArrayList<WebinarProgramDataModel>> response) {
                if (McbLiveWebinorActivity.this.mProgressbar != null && McbLiveWebinorActivity.this.mProgressbar.isShowing()) {
                    McbLiveWebinorActivity.this.mProgressbar.dismiss();
                }
                if (response == null || response.body() == null) {
                    Utility.showAlertDialog(McbLiveWebinorActivity.this.activity);
                    return;
                }
                new ArrayList();
                ArrayList arrayList = (ArrayList) response.body();
                if (arrayList == null || arrayList.size() <= 0) {
                    return;
                }
                WebinarProgramDataModel webinarProgramDataModel = (WebinarProgramDataModel) arrayList.get(0);
                String trim = webinarProgramDataModel.getSpeakerName().trim();
                String trim2 = webinarProgramDataModel.getProfilePic().trim();
                String trim3 = webinarProgramDataModel.getTitle().trim();
                String trim4 = webinarProgramDataModel.getDay().trim();
                String trim5 = webinarProgramDataModel.getCaption().trim();
                String trim6 = webinarProgramDataModel.getOutcomeOfProgram().trim();
                String trim7 = webinarProgramDataModel.getShortNote().trim();
                String trim8 = webinarProgramDataModel.getDesignation().trim();
                String trim9 = webinarProgramDataModel.getInformationAboutSpeaker().trim();
                McbLiveWebinorActivity.this.url = webinarProgramDataModel.getMeetingUrl();
                String meetingPwd = webinarProgramDataModel.getMeetingPwd();
                if (trim3.length() > 0) {
                    McbLiveWebinorActivity.this.mTitle.setText(Html.fromHtml(trim3));
                }
                if (trim5.length() > 0) {
                    McbLiveWebinorActivity.this.mCaption.setText(Html.fromHtml(trim5));
                }
                if (trim4.length() > 0) {
                    McbLiveWebinorActivity.this.mDateTime.setText(Html.fromHtml(trim4));
                }
                if (trim2.length() > 0) {
                    Glide.with(McbLiveWebinorActivity.this.context).load(trim2).apply(new RequestOptions().circleCrop()).into(McbLiveWebinorActivity.this.mSpeakerImg);
                }
                if (trim.length() > 0) {
                    McbLiveWebinorActivity.this.mSpeaker.setText(Html.fromHtml(trim));
                }
                if (trim8.length() > 0) {
                    McbLiveWebinorActivity.this.mDesignation.setText(Html.fromHtml(trim8));
                }
                if (trim9.length() > 0) {
                    McbLiveWebinorActivity.this.mInfo.setText(Html.fromHtml(trim9));
                }
                if (McbLiveWebinorActivity.this.registrationStatus == 1) {
                    if (McbLiveWebinorActivity.this.url == null || McbLiveWebinorActivity.this.url.length() <= 0 || McbLiveWebinorActivity.this.url.equalsIgnoreCase("null")) {
                        McbLiveWebinorActivity.this.mUrl.setVisibility(8);
                    } else {
                        McbLiveWebinorActivity.this.mUrl.setText(McbLiveWebinorActivity.this.url);
                        McbLiveWebinorActivity.this.mUrl.setPaintFlags(8);
                        McbLiveWebinorActivity.this.mUrl.setVisibility(0);
                    }
                    if (meetingPwd == null || meetingPwd.length() <= 0 || meetingPwd.equalsIgnoreCase("null")) {
                        McbLiveWebinorActivity.this.mPassword.setVisibility(8);
                    } else {
                        McbLiveWebinorActivity.this.mPassword.setText("Password : " + meetingPwd);
                        McbLiveWebinorActivity.this.mPassword.setVisibility(0);
                    }
                } else {
                    McbLiveWebinorActivity.this.mUrl.setVisibility(8);
                    McbLiveWebinorActivity.this.mPassword.setVisibility(8);
                }
                try {
                    McbLiveWebinorActivity.this.mShortNote.loadData(Base64.encodeToString(trim7.getBytes(C.UTF8_NAME), 0), "text/html; charset=utf-8", "base64");
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
                try {
                    McbLiveWebinorActivity.this.mAboutProgramPoints.loadData(Base64.encodeToString(trim6.getBytes(C.UTF8_NAME), 0), "text/html; charset=utf-8", "base64");
                } catch (UnsupportedEncodingException e2) {
                    e2.printStackTrace();
                }
                McbLiveWebinorActivity.this.mMainRL.setVisibility(0);
            }

            public void onFailure(Call<ArrayList<WebinarProgramDataModel>> call, Throwable th) {
                if (McbLiveWebinorActivity.this.mProgressbar != null && McbLiveWebinorActivity.this.mProgressbar.isShowing()) {
                    McbLiveWebinorActivity.this.mProgressbar.dismiss();
                }
                Utility.showAlertDialog(McbLiveWebinorActivity.this.activity);
            }
        });
    }

    private void saveWebinarProgramRegistrationDetails() {
        ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
        if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
            saveWebinarProgramRegistration();
        } else {
            Toast.makeText(this.context, "Check your Network Connection", 0).show();
        }
    }

    private void saveWebinarProgramRegistration() {
        TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
        if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
            this.mProgressbar.show();
        }
        HashMap hashMap = new HashMap();
        hashMap.put("LiveClassSubscribersDetailID", String.valueOf(this.subscriberId));
        hashMap.put("WebinarProgramID", String.valueOf(this.programId));
        hashMap.put("Mobile", this.mobile);
        hashMap.put("StudentName", this.studentName);
        hashMap.put("EmailAddress", this.emailAddress);
        hashMap.put("FatherName", this.fatherName);
        hashMap.put("SchoolName", this.schoolName);
        hashMap.put("apikey", Utility.getSchoolApiKey(this.context));
        ((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).SaveWebinarProgramRegistration(hashMap).enqueue(new Callback<SavingResponseModel>() {
            public void onResponse(Call<SavingResponseModel> call, Response<SavingResponseModel> response) {
                if (McbLiveWebinorActivity.this.mProgressbar != null && McbLiveWebinorActivity.this.mProgressbar.isShowing()) {
                    McbLiveWebinorActivity.this.mProgressbar.dismiss();
                }
                if (response == null || response.body() == null) {
                    Utility.showAlertDialog(McbLiveWebinorActivity.this.activity);
                    return;
                }
                SavingResponseModel savingResponseModel = (SavingResponseModel) response.body();
                final int intValue = savingResponseModel.getStatus().intValue();
                String message = savingResponseModel.getMessage();
                AlertDialog.Builder builder = new AlertDialog.Builder(McbLiveWebinorActivity.this.activity);
                builder.setMessage(message).setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
                        if (intValue == 1) {
                            McbLiveWebinorActivity.this.setResult(100, new Intent());
                            McbLiveWebinorActivity.this.finish();
                        }
                    }
                }).setCancelable(false);
                builder.create().show();
            }

            public void onFailure(Call<SavingResponseModel> call, Throwable th) {
                if (McbLiveWebinorActivity.this.mProgressbar != null && McbLiveWebinorActivity.this.mProgressbar.isShowing()) {
                    McbLiveWebinorActivity.this.mProgressbar.dismiss();
                }
                Utility.showAlertDialog(McbLiveWebinorActivity.this.activity);
            }
        });
    }

    @Override
    public void onClick(View view) {
        if (view == this.mInterested) {
            if (this.registrationStatus == 0) {
                saveWebinarProgramRegistrationDetails();
            }
        } else if (view == this.mUrl) {
            startActivity(new Intent("android.intent.action.VIEW", Uri.parse(this.url)));
        }
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() == 16908332) {
            onBackPressed();
            return true;
        }
        return super.onOptionsItemSelected(menuItem);
    }
}