导航菜单

页面标题

页面副标题

Mantra Counter v25.01 - GroupWebService.java 源代码

正在查看: Mantra Counter v25.01 应用的 GroupWebService.java JAVA 源代码文件

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


package com.sweetedge.mantracounter.group;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.sweetedge.mantracounter.Authentication.VolleyMultipartRequest;
import java.io.ByteArrayOutputStream;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONArray;
import save_data.Const;
import sweetedge.extra.PLog;
import sweetedge.popup.PToast;
import sweetedge.preference.PSharedPreference;

public class GroupWebService {
    public static byte[] getFileDataFromDrawable(Bitmap bitmap) {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.PNG, 80, byteArrayOutputStream);
        return byteArrayOutputStream.toByteArray();
    }

    public static boolean isNetworkAvailable(Context context) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
        NetworkInfo activeNetworkInfo = connectivityManager != null ? connectivityManager.getActiveNetworkInfo() : null;
        return activeNetworkInfo != null && activeNetworkInfo.isConnected();
    }

    public static void createGroup(final Context context, final String str, final String str2, final String str3, final JSONArray jSONArray, final Bitmap bitmap, final String str4, final String str5, boolean z) {
        LoadingDialog.showD(context);
        final String str6 = System.currentTimeMillis() + "";
        final String str7 = str6 + "_" + str;
        if (z) {
            PLog.print("Uploading " + bitmap.getRowBytes());
            Volley.newRequestQueue(context).add(new StringRequest(1, GroupConst.createUrl, new Response.Listener<String>() {
                public void onResponse(String str8) {
                    LoadingDialog.hideD();
                    LoadingDialog.showD(context);
                    PLog.print(str8);
                    Volley.newRequestQueue(context).add(new VolleyMultipartRequest(1, "https://davdapranav.com/AppWebServices/Mantra/Upload_Img_MC_Group.php", new Response.Listener<NetworkResponse>() {
                        public void onResponse(NetworkResponse networkResponse) {
                            LoadingDialog.hideD();
                            String str9 = new String(networkResponse.data);
                            PLog.print("Result = ".concat(str9));
                            if (str9.length() <= 0 || !str9.contains("Group Created")) {
                                return;
                            }
                            PToast.showT(context, "Group Created");
                            Create_Group.is_creating_group = true;
                            ((Activity) context).finish();
                            GroupWebService.NotifyGroupMembers(context, str, jSONArray.toString(), str6, "0");
                        }
                    }, new Response.ErrorListener() {
                        public void onErrorResponse(VolleyError volleyError) {
                            LoadingDialog.hideD();
                            PToast.showT(context, "The server is down, Please try after some time!");
                            PLog.print("GotError" + volleyError.getMessage());
                        }
                    }) {
                        protected Map<String, String> getParams() throws AuthFailureError {
                            HashMap hashMap = new HashMap();
                            hashMap.put("WHAT", "UPLOAD");
                            hashMap.put("GID", str7);
                            hashMap.put("IMAGENAME", str6);
                            return hashMap;
                        }

                        @Override
                        protected Map<String, VolleyMultipartRequest.DataPart> getByteData() {
                            HashMap hashMap = new HashMap();
                            hashMap.put("image", new VolleyMultipartRequest.DataPart(str6 + ".png", GroupWebService.getFileDataFromDrawable(bitmap)));
                            return hashMap;
                        }
                    });
                }
            }, new Response.ErrorListener() {
                public void onErrorResponse(VolleyError volleyError) {
                    LoadingDialog.hideD();
                    PToast.showT(context, "The server is down, Please try after some time!");
                    Log.e("Response Error", "" + volleyError);
                }
            }) {
                protected Map<String, String> getParams() {
                    HashMap hashMap = new HashMap();
                    hashMap.put("Admin", PSharedPreference.getString(context, Const.GMAIL, "null"));
                    hashMap.put("GID", str7);
                    hashMap.put("GName", str);
                    hashMap.put("GTarget", str2);
                    hashMap.put("GMantraSound", str5);
                    hashMap.put("GTheme", str3);
                    hashMap.put("IMAGENAME", str6);
                    hashMap.put("JSON", jSONArray.toString());
                    return hashMap;
                }
            });
            return;
        }
        Volley.newRequestQueue(context).add(new StringRequest(1, GroupConst.createUrl, new Response.Listener<String>() {
            public void onResponse(String str8) {
                LoadingDialog.hideD();
                PLog.print(str8);
                if (str8.length() > 0) {
                    PToast.showT(context, "Group Created");
                    Create_Group.is_creating_group = true;
                    ((Activity) context).finish();
                    GroupWebService.NotifyGroupMembers(context, str, jSONArray.toString(), str4, "1");
                }
            }
        }, new Response.ErrorListener() {
            public void onErrorResponse(VolleyError volleyError) {
                LoadingDialog.hideD();
                PToast.showT(context, "The server is down, Please try after some time!");
                Log.e("Response Error", "" + volleyError);
            }
        }) {
            protected Map<String, String> getParams() {
                HashMap hashMap = new HashMap();
                hashMap.put("Admin", PSharedPreference.getString(context, Const.GMAIL, "null"));
                hashMap.put("GID", str7);
                hashMap.put("isLive", "0");
                hashMap.put("GName", str);
                hashMap.put("GTarget", str2);
                hashMap.put("GMantraSound", str5);
                hashMap.put("GTheme", str3);
                hashMap.put("IMAGENAME", str4);
                hashMap.put("JSON", jSONArray.toString());
                return hashMap;
            }
        });
    }

    public static void NotifyGroupMembers(final Context context, final String str, final String str2, final String str3, final String str4) {
        Volley.newRequestQueue(context).add(new StringRequest(1, GroupConst.notifyGroupMember, new Response.Listener<String>() {
            public void onResponse(String str5) {
                PLog.print("Notify Member Response = " + str5);
            }
        }, new Response.ErrorListener() {
            public void onErrorResponse(VolleyError volleyError) {
                PToast.showT(context, "The server is down, Please try after some time!");
                PLog.print("Response Error" + volleyError + " = " + volleyError.getMessage());
            }
        }) {
            protected Map<String, String> getParams() {
                HashMap hashMap = new HashMap();
                hashMap.put("GName", str);
                hashMap.put("Gimage", str3);
                hashMap.put("isLive", str4);
                hashMap.put("JSON", str2);
                PLog.print("Notify JSon = " + str2 + "  Gname = " + str + " Gimage = " + str3 + " isLocal = " + str4);
                return hashMap;
            }
        });
    }

    public static void ExitGroup(final Context context, final String str) {
        Volley.newRequestQueue(context).add(new StringRequest(1, GroupConst.exitGroup, new Response.Listener<String>() {
            public void onResponse(String str2) {
                PToast.showT(context, str2.trim());
                ((Activity) context).finish();
            }
        }, new Response.ErrorListener() {
            public void onErrorResponse(VolleyError volleyError) {
                PToast.showT(context, "The server is down, Please try after some time!");
                PLog.print("Response Error" + volleyError + " = " + volleyError.getMessage());
            }
        }) {
            protected Map<String, String> getParams() {
                HashMap hashMap = new HashMap();
                hashMap.put("GID", str);
                hashMap.put("Gmail", PSharedPreference.getString(context, Const.GMAIL, "null"));
                return hashMap;
            }
        });
    }

    public static void updateJapaCounteronServer(final Context context, final long j, long j2, final String str) {
        if (str.equals("null") || str.length() < 5) {
            PLog.print("Please Make Login !");
            return;
        }
        if (PSharedPreference.getBoolean(context, GroupConst.isPublic, false)) {
            if (j <= j2) {
                Volley.newRequestQueue(context).add(new StringRequest(1, GroupConst.groupMantraCounterUpdate, new Response.Listener<String>() {
                    public void onResponse(String str2) {
                        if (str2.length() <= 0 || !str2.contains("Completed")) {
                            return;
                        }
                        PSharedPreference.setBoolean(context, GroupConst.isGroup, false);
                        PSharedPreference.setString(context, GroupConst.Grpid, "null");
                    }
                }, new Response.ErrorListener() {
                    public void onErrorResponse(VolleyError volleyError) {
                        PToast.showT(context, "The server is down, Please try after some time!");
                        PLog.print("Response Error" + volleyError + " = " + volleyError.getMessage());
                    }
                }) {
                    protected Map<String, String> getParams() {
                        HashMap hashMap = new HashMap();
                        hashMap.put("GID", PSharedPreference.getString(context, GroupConst.Grpid, "null"));
                        hashMap.put("Gmail", str);
                        hashMap.put("MantraCounter", j + "");
                        hashMap.put("isPublic", String.valueOf(true));
                        return hashMap;
                    }
                });
            }
        } else if (j <= j2) {
            Volley.newRequestQueue(context).add(new StringRequest(1, GroupConst.groupMantraCounterUpdate, new Response.Listener<String>() {
                public void onResponse(String str2) {
                    if (str2.length() > 0) {
                        PToast.showT(context, str2);
                    }
                }
            }, new Response.ErrorListener() {
                public void onErrorResponse(VolleyError volleyError) {
                    PToast.showT(context, "The server is down, Please try after some time!");
                    PLog.print("Response Error" + volleyError + " = " + volleyError.getMessage());
                }
            }) {
                protected Map<String, String> getParams() {
                    HashMap hashMap = new HashMap();
                    hashMap.put("GID", PSharedPreference.getString(context, GroupConst.Grpid, "null"));
                    hashMap.put("Gmail", str);
                    hashMap.put("MantraCounter", j + "");
                    hashMap.put("isPublic", String.valueOf(false));
                    return hashMap;
                }
            });
        }
    }
}