正在查看: Mantra Counter v25.01 应用的 MyGroup.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Mantra Counter v25.01 应用的 MyGroup.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.sweetedge.mantracounter.group;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.PopupMenu;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.commons.cli.HelpFormatter;
import com.sweetedge.mantracounter.Authentication.UserWebService;
import com.sweetedge.mantracounter.MainActivity;
import com.sweetedge.mantracounter.R;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import save_data.Const;
import sweetedge.extra.PLog;
import sweetedge.popup.PDialog;
import sweetedge.popup.PToast;
import sweetedge.preference.PSharedPreference;
import sweetedge.screen.PIntent;
public class MyGroup extends AppCompatActivity {
static RecyclerView GroupListView;
static RecyclerView PublicListView;
AlertDialog GroupIntro;
ImageView MyQr;
LinearLayout NoGroupFound;
MyListAdapter adapter;
ImageView create_Group;
TextView personalGrp;
TextView publicGrp;
PublicGroupAdapter public_adapter;
ArrayList<MyGroupPojo> groupList = new ArrayList<>();
ArrayList<PublicGroupPojo> publicgroupList = new ArrayList<>();
protected void onResume() {
super.onResume();
LoadGroupListData();
}
private void LoadGroupListData() {
if (UserWebService.isNetworkAvailable(this)) {
getGroupbyNumber(this);
}
}
public void getGroupbyNumber(final Context context) {
LoadingDialog.showD(this);
PLog.print("Getting Group Data");
Volley.newRequestQueue(context).add(new StringRequest(1, GroupConst.getbyNumber, new Response.Listener<String>() {
public void onResponse(String str) {
JSONArray jSONArray;
JSONArray jSONArray2;
LoadingDialog.hideD();
try {
MyGroup.this.groupList.clear();
MyGroup.this.publicgroupList.clear();
PLog.print("Response= " + str);
JSONObject jSONObject = new JSONObject(str);
if (jSONObject.has("MyGroup") && !jSONObject.isNull("MyGroup") && (jSONArray2 = jSONObject.getJSONArray("MyGroup")) != null && jSONArray2.length() > 0) {
MyGroup.this.personalGrp.setText(jSONArray2.length() + HelpFormatter.DEFAULT_LONG_OPT_SEPARATOR + context.getString(R.string.personal_grp));
MyGroup.this.NoGroupFound.setVisibility(8);
for (int i = 0; i < jSONArray2.length(); i++) {
String string = jSONArray2.getJSONObject(i).getString("GroupId");
String string2 = jSONArray2.getJSONObject(i).getString("Mantra");
String string3 = jSONArray2.getJSONObject(i).getString("GroupName");
String string4 = jSONArray2.getJSONObject(i).getString("GroupTarget");
String string5 = jSONArray2.getJSONObject(i).getString("CounterTheme");
String string6 = jSONArray2.getJSONObject(i).getString("Status");
String string7 = jSONArray2.getJSONObject(i).getString("God_Img");
String string8 = jSONArray2.getJSONObject(i).getString("GodMantra");
String string9 = jSONArray2.getJSONObject(i).getString("Info");
String string10 = jSONArray2.getJSONObject(i).getString("CreateTime");
String string11 = jSONArray2.getJSONObject(i).getString("Completed");
String string12 = jSONArray2.getJSONObject(i).getString("GroupCount");
PLog.print("Group Count = " + string12);
if (!string6.equals(GroupConst.GroupDel)) {
MyGroup.this.groupList.add(new MyGroupPojo(string, string3, string2, string4, string5, string6, string7, string8, string9, string10, string12, string11));
}
}
}
if (jSONObject.has("PublicGroup") && !jSONObject.isNull("PublicGroup") && (jSONArray = jSONObject.getJSONArray("PublicGroup")) != null && jSONArray.length() > 0) {
MyGroup.this.NoGroupFound.setVisibility(8);
MyGroup.this.publicGrp.setText(jSONArray.length() + HelpFormatter.DEFAULT_LONG_OPT_SEPARATOR + context.getString(R.string.public_grp));
for (int i2 = 0; i2 < jSONArray.length(); i2++) {
String string13 = jSONArray.getJSONObject(i2).getString("GroupID");
String string14 = jSONArray.getJSONObject(i2).getString("GroupName");
String string15 = jSONArray.getJSONObject(i2).getString("GroupDesc");
String string16 = jSONArray.getJSONObject(i2).getString("GroupTarget");
String string17 = jSONArray.getJSONObject(i2).getString("GroupMantra");
String string18 = jSONArray.getJSONObject(i2).getString("GroupPhoto");
String string19 = jSONArray.getJSONObject(i2).getString("GroupTheme");
String string20 = jSONArray.getJSONObject(i2).getString("GroupNotes");
String string21 = jSONArray.getJSONObject(i2).getString("Status");
String string22 = jSONArray.getJSONObject(i2).getString("MEMBERS");
String string23 = jSONArray.getJSONObject(i2).getString("JOINED");
if (!string21.equals(GroupConst.GroupDel)) {
MyGroup.this.publicgroupList.add(new PublicGroupPojo(string13, string14, string15, string16, string17, string18, string19, string20, string21, string22, string23));
}
}
}
Collections.sort(MyGroup.this.groupList, new Comparator<MyGroupPojo>() {
@Override
public int compare(MyGroupPojo myGroupPojo, MyGroupPojo myGroupPojo2) {
return myGroupPojo.Info.compareTo(myGroupPojo2.Info);
}
});
Collections.sort(MyGroup.this.publicgroupList, new Comparator<PublicGroupPojo>() {
@Override
public int compare(PublicGroupPojo publicGroupPojo, PublicGroupPojo publicGroupPojo2) {
return publicGroupPojo.grpName.compareTo(publicGroupPojo2.grpName);
}
});
MyGroup.GroupListView.setHasFixedSize(true);
MyGroup.GroupListView.setLayoutManager(new GridLayoutManager(context, 1));
MyGroup myGroup = MyGroup.this;
MyGroup myGroup2 = MyGroup.this;
myGroup.adapter = myGroup2.new MyListAdapter(context, myGroup2.groupList);
MyGroup.GroupListView.setAdapter(MyGroup.this.adapter);
MyGroup.PublicListView.setHasFixedSize(true);
MyGroup.PublicListView.setLayoutManager(new GridLayoutManager(context, 1));
MyGroup.this.public_adapter = new PublicGroupAdapter(context, MyGroup.this.publicgroupList);
MyGroup.PublicListView.setAdapter(MyGroup.this.public_adapter);
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
}, new Response.ErrorListener() {
public void onErrorResponse(VolleyError volleyError) {
LoadingDialog.hideD();
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("Gmail", PSharedPreference.getString(context, Const.GMAIL, "null"));
return hashMap;
}
});
}
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
MainActivity.setLanguage(this);
setContentView(R.layout.activity_my_group);
GroupListView = findViewById(R.id.group_list);
PublicListView = findViewById(R.id.publicgroup_list);
this.create_Group = (ImageView) findViewById(R.id.createGroup);
this.NoGroupFound = (LinearLayout) findViewById(R.id.noGroupFound);
this.personalGrp = (TextView) findViewById(R.id.personal_Grp);
this.publicGrp = (TextView) findViewById(R.id.public_Grp);
this.MyQr = (ImageView) findViewById(R.id.myQR);
this.NoGroupFound.setVisibility(0);
this.NoGroupFound.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
MyGroup.this.create_Group.performClick();
}
});
this.create_Group.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (UserWebService.isNetworkAvailable(MyGroup.this)) {
MyGroup.this.showGroupInfoDialog();
} else {
PToast.showT(MyGroup.this, "No Connection");
}
}
});
this.MyQr.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PIntent.goNewScreen(MyGroup.this, GenerateQR.class);
}
});
}
public void showGroupInfoDialog() {
View inflate = LayoutInflater.from(this).inflate(R.layout.group_intro, (ViewGroup) null);
TextView textView = (TextView) inflate.findViewById(R.id.moveon);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(inflate);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
MyGroup.this.GroupIntro.dismiss();
PIntent.goNewScreen(MyGroup.this, Create_Group.class);
}
});
AlertDialog create = builder.create();
this.GroupIntro = create;
create.show();
}
public class MyListAdapter extends RecyclerView.Adapter<ViewHolder> {
ArrayList<MyGroupPojo> _data;
Context c;
public MyListAdapter(Context context, ArrayList<MyGroupPojo> arrayList) {
this._data = arrayList;
this.c = context;
}
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.group_item_grid, (ViewGroup) null, false);
inflate.setLayoutParams(new RecyclerView.LayoutParams(-1, -2));
return new ViewHolder(inflate);
}
public void onBindViewHolder(final ViewHolder viewHolder, int i) {
final MyGroupPojo myGroupPojo = this._data.get(i);
viewHolder.TV_name.setText(myGroupPojo.name);
if (myGroupPojo.completed.equals("1")) {
Drawable drawable = ContextCompat.getDrawable(this.c, R.drawable.completed);
drawable.setBounds(0, 0, 60, 60);
viewHolder.TV_name.setCompoundDrawables(null, null, drawable, null);
}
Glide.with(this.c).load(Uri.parse(myGroupPojo.group_img)).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).into(new CustomTarget<Drawable>() {
public void onLoadCleared(Drawable drawable2) {
}
public void onResourceReady(Object obj, Transition transition) {
onResourceReady((Drawable) obj, (Transition<? super Drawable>) transition);
}
public void onResourceReady(Drawable drawable2, Transition<? super Drawable> transition) {
if (drawable2 == null) {
PLog.print("Null");
} else {
viewHolder.God_img.setImageDrawable(drawable2);
viewHolder.drawable_img = drawable2;
}
}
});
viewHolder.TV_japa.setText(this._data.get(i).mantra);
viewHolder.TV_id.setText(this._data.get(i).id);
viewHolder.Tv_Target.setText(this._data.get(i).target);
viewHolder.TV_Member.setText(myGroupPojo.groupMemberCount + HelpFormatter.DEFAULT_LONG_OPT_SEPARATOR + MyGroup.this.getResources().getString(R.string.members));
if (this._data.get(i).id.equals(PSharedPreference.getString(this.c, GroupConst.Grpid, "null"))) {
viewHolder.TV_name.setTypeface(null, 1);
} else {
viewHolder.TV_name.setTypeface(null, 0);
}
if (myGroupPojo.Info.equals("Admin")) {
viewHolder.TV_manage.setText(MyGroup.this.getResources().getString(R.string.admin));
viewHolder.PendingLayout.setVisibility(8);
} else if (myGroupPojo.status.equals("Pending")) {
viewHolder.TV_manage.setText(MyGroup.this.getResources().getString(R.string.invite_to_group));
viewHolder.PendingLayout.setVisibility(0);
} else {
viewHolder.PendingLayout.setVisibility(8);
viewHolder.TV_manage.setVisibility(8);
}
viewHolder.BtApprove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (UserWebService.isNetworkAvailable(MyGroup.this)) {
MyGroup.this.setGroupStatus(MyListAdapter.this.c, myGroupPojo.id, GroupConst.GroupJoin);
viewHolder.PendingLayout.setVisibility(8);
} else {
PToast.showT(MyListAdapter.this.c, "No Connection");
}
}
});
viewHolder.BtDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (UserWebService.isNetworkAvailable(MyGroup.this)) {
MyGroup.this.setGroupStatus(MyListAdapter.this.c, myGroupPojo.id, GroupConst.GroupDel);
} else {
PToast.showT(MyListAdapter.this.c, "No Connection");
}
}
});
viewHolder.God_img.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (UserWebService.isNetworkAvailable(MyGroup.this)) {
MyGroup.setGroupInfoData(myGroupPojo.id, myGroupPojo.target, myGroupPojo.Info, myGroupPojo.name, viewHolder.drawable_img, myGroupPojo.group_img, myGroupPojo.created);
PIntent.goNewScreen(MyGroup.this, GroupInfoPage.class);
} else {
PToast.showT(MyListAdapter.this.c, "No Connection");
}
}
});
viewHolder.TV_name.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
viewHolder.Menu.performClick();
}
});
viewHolder.layout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
viewHolder.Menu.performClick();
}
});
viewHolder.Menu.setOnClickListener(new AnonymousClass7(myGroupPojo, viewHolder, i));
}
class AnonymousClass7 implements View.OnClickListener {
final MyGroupPojo val$current;
final ViewHolder val$holder;
final int val$pos;
AnonymousClass7(MyGroupPojo myGroupPojo, ViewHolder viewHolder, int i) {
this.val$current = myGroupPojo;
this.val$holder = viewHolder;
this.val$pos = i;
}
@Override
public void onClick(View view) {
if (this.val$current.Info.equals("Admin")) {
PopupMenu popupMenu = new PopupMenu(MyGroup.this, this.val$holder.Menu);
popupMenu.inflate(R.menu.group_list_admin);
final MenuItem findItem = popupMenu.getMenu().findItem(R.id.stop_m);
final MenuItem findItem2 = popupMenu.getMenu().findItem(R.id.start_m);
if (MyListAdapter.this._data.get(this.val$pos).id.equals(PSharedPreference.getString(MyListAdapter.this.c, GroupConst.Grpid, "null"))) {
findItem2.setVisible(false);
findItem.setVisible(true);
} else {
findItem.setVisible(false);
findItem2.setVisible(true);
}
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem menuItem) {
int itemId = menuItem.getItemId();
if (itemId == R.id.info) {
MyGroup.setGroupInfoData(AnonymousClass7.this.val$current.id, AnonymousClass7.this.val$current.target, AnonymousClass7.this.val$current.Info, AnonymousClass7.this.val$current.name, AnonymousClass7.this.val$holder.drawable_img, AnonymousClass7.this.val$current.group_img, AnonymousClass7.this.val$current.created);
PIntent.goNewScreen(MyGroup.this, GroupInfoPage.class);
} else if (itemId == R.id.start_m) {
MyGroup.this.startGroupChanting(AnonymousClass7.this.val$current);
} else if (itemId == R.id.stop_m) {
PSharedPreference.setBoolean(MyListAdapter.this.c, GroupConst.isGroup, false);
PSharedPreference.setString(MyListAdapter.this.c, GroupConst.Grpid, "null");
findItem.setVisible(false);
findItem2.setVisible(true);
} else if (itemId == R.id.delete_grp) {
DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (i == -1) {
MyGroup.this.setGroupStatus(MyListAdapter.this.c, AnonymousClass7.this.val$current.id, GroupConst.GroupDelAll);
}
}
};
if (UserWebService.isNetworkAvailable(MyGroup.this)) {
PDialog.showSimple(MyGroup.this, onClickListener, MyGroup.this.getResources().getString(R.string.deleteGroup), MyGroup.this.getResources().getString(R.string.deleteGroup) + HelpFormatter.DEFAULT_LONG_OPT_SEPARATOR + AnonymousClass7.this.val$current.name + " ?", MyGroup.this.getResources().getString(R.string.delete), MyGroup.this.getResources().getString(R.string.cancel));
} else {
PToast.showT(MyListAdapter.this.c, "No Connection");
}
}
return true;
}
});
popupMenu.show();
return;
}
PopupMenu popupMenu2 = new PopupMenu(MyGroup.this, this.val$holder.Menu);
popupMenu2.inflate(R.menu.group_list);
final MenuItem findItem3 = popupMenu2.getMenu().findItem(R.id.stop_m);
final MenuItem findItem4 = popupMenu2.getMenu().findItem(R.id.start_m);
if (MyListAdapter.this._data.get(this.val$pos).id.equals(PSharedPreference.getString(MyListAdapter.this.c, GroupConst.Grpid, "null"))) {
findItem4.setVisible(false);
findItem3.setVisible(true);
} else {
findItem3.setVisible(false);
findItem4.setVisible(true);
}
popupMenu2.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem menuItem) {
int itemId = menuItem.getItemId();
if (itemId == R.id.info) {
MyGroup.setGroupInfoData(AnonymousClass7.this.val$current.id, AnonymousClass7.this.val$current.target, AnonymousClass7.this.val$current.Info, AnonymousClass7.this.val$current.name, AnonymousClass7.this.val$holder.drawable_img, AnonymousClass7.this.val$current.group_img, AnonymousClass7.this.val$current.created);
PIntent.goNewScreen(MyGroup.this, GroupInfoPage.class);
} else if (itemId == R.id.start_m) {
if (AnonymousClass7.this.val$current.status.equals(GroupConst.GroupJoin)) {
MyGroup.this.startGroupChanting(AnonymousClass7.this.val$current);
} else {
PToast.showT(MyGroup.this, MyGroup.this.getResources().getString(R.string.approve_group_request));
}
} else if (itemId == R.id.stop_m) {
PSharedPreference.setBoolean(MyListAdapter.this.c, GroupConst.isGroup, false);
PSharedPreference.setString(MyListAdapter.this.c, GroupConst.Grpid, "null");
findItem3.setVisible(false);
findItem4.setVisible(true);
} else if (itemId == R.id.delete) {
DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (i == -1) {
MyGroup.this.setGroupStatus(MyListAdapter.this.c, AnonymousClass7.this.val$current.id, GroupConst.GroupDel);
}
}
};
if (UserWebService.isNetworkAvailable(MyGroup.this)) {
PDialog.showSimple(MyGroup.this, onClickListener, MyGroup.this.getResources().getString(R.string.deleteGroup), MyGroup.this.getResources().getString(R.string.deleteGroup) + HelpFormatter.DEFAULT_LONG_OPT_SEPARATOR + AnonymousClass7.this.val$current.name + " ?", MyGroup.this.getResources().getString(R.string.delete), MyGroup.this.getResources().getString(R.string.cancel));
} else {
PToast.showT(MyListAdapter.this.c, "No Connection");
}
}
return true;
}
});
popupMenu2.show();
}
}
public int getItemCount() {
return this._data.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
public TextView BtApprove;
public TextView BtDelete;
public ImageView God_img;
public ImageView Menu;
LinearLayout PendingLayout;
public TextView TV_Member;
public TextView TV_id;
public TextView TV_japa;
public TextView TV_manage;
public TextView TV_name;
public TextView Tv_Target;
Drawable drawable_img;
RelativeLayout layout;
public ViewHolder(View view) {
super(view);
this.layout = (RelativeLayout) view.findViewById(R.id.relativeLayout_g);
this.Menu = (ImageView) view.findViewById(R.id.menu_icon_g);
this.God_img = (ImageView) view.findViewById(R.id.god_img_g);
this.TV_manage = (TextView) view.findViewById(R.id.imanage_g);
this.TV_japa = (TextView) view.findViewById(R.id.textView_counter_g);
this.TV_name = (TextView) view.findViewById(R.id.textView_name_g);
this.TV_id = (TextView) view.findViewById(R.id.textView_id_g);
this.Tv_Target = (TextView) view.findViewById(R.id.textView_target_g);
this.PendingLayout = (LinearLayout) view.findViewById(R.id.pendingLayout);
this.TV_Member = (TextView) view.findViewById(R.id.textview_member);
this.BtApprove = (TextView) view.findViewById(R.id.approve);
this.BtDelete = (TextView) view.findViewById(R.id.delete);
}
}
}
public void startGroupChanting(MyGroupPojo myGroupPojo) {
PSharedPreference.setBoolean(this, GroupConst.isGroup, true);
PSharedPreference.setBoolean(this, GroupConst.isPublic, false);
GroupConst.setGroupChantingFeatureData(this, myGroupPojo.id, myGroupPojo.name, myGroupPojo.target, myGroupPojo.group_img, myGroupPojo.group_mantra, myGroupPojo.theme, myGroupPojo.mantra);
finish();
}
public static void setGroupInfoData(String str, String str2, String str3, String str4, Drawable drawable, String str5, String str6) {
GroupInfoPage.GroupId = str;
GroupInfoPage.GroupName = str4;
GroupInfoPage.GroupCreated = str6;
GroupInfoPage.GroupTarget = str2;
GroupInfoPage.GroupInfo = str3;
GroupInfoPage.groupImageDrawable = drawable;
GroupInfoPage.GroupImage = str5;
}
public void setGroupStatus(final Context context, final String str, final String str2) {
Volley.newRequestQueue(context).add(new StringRequest(1, GroupConst.groupStatusUpdate, new Response.Listener<String>() {
public void onResponse(String str3) {
PLog.print("Response = " + str3);
MyGroup.this.getGroupbyNumber(context);
}
}, new Response.ErrorListener() {
public void onErrorResponse(VolleyError volleyError) {
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("WHAT", str2);
hashMap.put("Gmail", PSharedPreference.getString(context, Const.GMAIL, "null"));
hashMap.put("GID", str);
return hashMap;
}
});
}
}