<file_sep>package com.hm.application.network;

import android.util.Log;

import com.android.volley.NetworkResponse;
import com.android.volley.Response;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import com.android.volley.toolbox.HttpHeaderParser;
import com.android.volley.toolbox.JsonRequest;
import com.crashlytics.android.Crashlytics;

import org.json.JSONObject;

public class GetObjRequest extends JsonRequest<JSONObject> {

    public GetObjRequest(String url, JSONObject jsonObject, Listener<JSONObject> listener, ErrorListener errorListener) {
        super(Method.GET, url, jsonObject.toString(), listener, errorListener);
        Log.d("HM_URL", " Get Obj Req: " + url + " : " + jsonObject.toString());
    }

    protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
        try {
            Log.d("HM_URL", " Get Obj Resp: " + response.statusCode + " : " + response.networkTimeMs);
            return Response.success(new JSONObject(new String(response.data, HttpHeaderParser.parseCharset(response.headers))), HttpHeaderParser.parseCacheHeaders(response));
        } catch (Exception | Error e) {
            e.printStackTrace(); Crashlytics.logException(e);

            return null;
        }
    }
}<file_sep>package com.hm.application.network;

import android.content.Context;

import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.HttpHeaderParser;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.StringRequest;
import com.crashlytics.android.Crashlytics;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class VolleyUtils {

    String request;

    public static void POST_METHOD(Context context, String url, final Map<String, String> getParams, final VolleyResponseListener listener) {

        // Initialize a new StringRequest
        StringRequest stringRequest = new StringRequest(
                Request.Method.POST,
                url,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        listener.onResponse(response);

                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        listener.onError(error.toString());

                    }
                })

        {

            /**
             * Passing some request headers
             * */
            @Override
            public Map<String, String> getHeaders() {
                HashMap<String, String> headers = new HashMap<String, String>();
                getParams.put("Content-Type", "application/json; charset=utf-8");
                return headers;
            }

        };

        // Access the RequestQueue through singleton class.
        VolleySingleton.getInstance(context).addToRequestQueue(stringRequest, "TAG " + stringRequest);
    }

    public static void makeJsonObjectRequest(Context context, String url, final VolleyResponseListener listener) {
        JsonObjectRequest jsonObjectRequest = new JsonObjectRequest
                (url, null, new Response.Listener<JSONObject>() {

                    @Override
                    public void onResponse(JSONObject response) {
                        listener.onResponse(response);
                    }
                }, new Response.ErrorListener() {

                    @Override
                    public void onErrorResponse(VolleyError error) {
                        listener.onError(error.toString());
                    }
                }) {

            @Override
            protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
                try {
                    String jsonString = new String(response.data,
                            HttpHeaderParser.parseCharset(response.headers, PROTOCOL_CHARSET));
                    return Response.success(new JSONObject(jsonString),
                            HttpHeaderParser.parseCacheHeaders(response));
                } catch (Exception | Error e) {
                    e.printStackTrace(); Crashlytics.logException(e);

                    return Response.error(new ParseError(e));
                }
            }
        };

        // Access the RequestQueue through singleton class.
        VolleySingleton.getInstance(context).addToRequestQueue(jsonObjectRequest);
    }

}
<file_sep>package com.hm.application.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;

import com.hm.application.R;
import com.hm.application.model.AppConstants;
import com.hm.application.model.AppDataStorage;
import com.hm.application.model.User;
import com.hm.application.services.MyFirebaseInstanceIDService;
import com.hm.application.user_data.LoginActivity;

public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                AppDataStorage.getUserInfo(SplashActivity.this);
                new MyFirebaseInstanceIDService().onTokenRefresh();
                if (User.getUser(SplashActivity.this).getUid() != null) {
                    startActivity(new Intent(SplashActivity.this, MainHomeActivity.class));
                } else {
                    startActivity(new Intent(SplashActivity.this, LoginActivity.class).putExtra(AppConstants.USERDATA, AppConstants.LOGIN));
                }
                finish();
            }
        }, 1000);
    }
}<file_sep>package com.hm.application.fragments;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.crashlytics.android.Crashlytics;
import com.hm.application.R;
import com.hm.application.adapter.DisplayReplyAdapter;
import com.hm.application.model.AppConstants;
import com.hm.application.model.User;
import com.hm.application.network.VolleySingleton;
import com.hm.application.utils.CommonFunctions;
import com.hm.application.utils.HmFonts;
import com.squareup.picasso.Picasso;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

import de.hdodenhof.circleimageview.CircleImageView;

public class ReplyToCommentFragment extends Fragment {

    public String commentId = null;
    private RecyclerView mRv;
    //    private TextView mTvLikesData;
    private EditText mEdtCmt;
    private Button mBtnCmt;
    private LinearLayout mLlAddCmt;
    //    private RelativeLayout mllCuCall;
    private ImageView mIvProfilePic;

    public ReplyToCommentFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_comment, container, false);
    }


    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        try {
            toBindViews();
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);

        }
    }

    private void checkInternetConnection() throws Error {
        if (CommonFunctions.isOnline(getContext())) {
            toDisplayReply();
        } else {
            CommonFunctions.toDisplayToast(getResources().getString(R.string.lbl_no_check_internet), getContext());
        }
    }

    @NonNull
    private void toBindViews() throws Error {
        mRv = getActivity().findViewById(R.id.rvComments);
        mRv.setNestedScrollingEnabled(false);
//        mTvLikesData = getActivity().findViewById(R.id.txtCmtData);
        mEdtCmt = getActivity().findViewById(R.id.edtCfPost);
        mBtnCmt = getActivity().findViewById(R.id.btnCfSend);
        mLlAddCmt = getActivity().findViewById(R.id.llAddCmt);
//        mllCuCall = getActivity().findViewById(R.id.llCuCall);
//        mllCuCall.setVisibility(View.VISIBLE);

        mIvProfilePic = getActivity().findViewById(R.id.imgCf);
        if (User.getUser(getContext()).getPicPath() != null) {
            Picasso.with(getContext())
                    .load(AppConstants.URL + User.getUser(getContext()).getPicPath().replaceAll("\\s", "%20"))
                    .resize(200, 200)
                    .error(R.color.light2)
                    .placeholder(R.color.light)
                    .into(mIvProfilePic);
        }


        if (getArguments() != null) {
            if (getArguments().getString(AppConstants.COMMENT_ID) != null) {
                commentId = getArguments().getString(AppConstants.COMMENT_ID);
                toAddComment(getArguments().getString("Data"));
                checkInternetConnection();
            } else {
                CommonFunctions.toDisplayToast("No Reply", getContext());
            }
        } else {
            CommonFunctions.toDisplayToast("No Reply", getContext());
        }

        mEdtCmt.setOnEditorActionListener(new EditText.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    toSubmitReply();
                }
                return false;
            }
        });

        mBtnCmt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                toSubmitReply();
            }
        });
    }

    private void toAddComment(String data) {
        try {
            JSONObject obj = new JSONObject(data);
            CircleImageView mIvCu;
            TextView mTvCuName, mTvCuCmt, mTvCuTime, mTvCuLike, mTvCuReply;

            mIvCu = getActivity().findViewById(R.id.imgCu);
            if (!obj.isNull(getContext().getString(R.string.str_profile_pic))) {
                if (obj.getString(getContext().getString(R.string.str_profile_pic)).toLowerCase().contains("upload")) {
                    Picasso.with(getContext()).load(AppConstants.URL + obj.getString(getContext().getString(R.string.str_profile_pic))).placeholder(R.color.light).error(R.color.light2).into(mIvCu);
                } else {
                    Picasso.with(getContext()).load(obj.getString(getContext().getString(R.string.str_profile_pic))).placeholder(R.color.light).error(R.color.light2).into(mIvCu);
                }
            }

            mTvCuName = getActivity().findViewById(R.id.txtCuName);
            mTvCuName.setTypeface(HmFonts.getRobotoBold(getContext()));
            if (!obj.isNull(getContext().getString(R.string.str_username_))) {
                mTvCuName.setText(obj.getString(getContext().getString(R.string.str_username_)));
            }

            mTvCuCmt = getActivity().findViewById(R.id.txtCuCmt);
            mTvCuCmt.setTypeface(HmFonts.getRobotoRegular(getContext()));
            if (!obj.isNull(getContext().getString(R.string.str_comment_small))) {
                mTvCuCmt.setText(obj.getString(getContext().getString(R.string.str_comment_small)));
            }


            mTvCuTime = getActivity().findViewById(R.id.txtCuTime);
            mTvCuTime.setTypeface(HmFonts.getRobotoRegular(getContext()));
            if (!obj.isNull(getContext().getString(R.string.str_time_small))) {
                mTvCuTime.setText(CommonFunctions.toSetDate(obj.getString(getContext().getString(R.string.str_time_small))));
            }

            mTvCuLike = getActivity().findViewById(R.id.txtCuLike);
            mTvCuLike.setTypeface(HmFonts.getRobotoRegular(getContext()));
            if (!obj.isNull(getContext().getString(R.string.str_like_count))) {
                mTvCuLike.setText(obj.getString(getContext().getString(R.string.str_like_count)) + " " + getContext().getString(R.string.str_like));
            }

            mTvCuReply = getActivity().findViewById(R.id.txtCuReply);
            mTvCuReply.setTypeface(HmFonts.getRobotoRegular(getContext()));
            if (!obj.isNull(getContext().getString(R.string.str_reply_count))) {
                mTvCuReply.setText(obj.getString(getContext().getString(R.string.str_reply_count)) + " " + getContext().getString(R.string.str_reply));
            }
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);

        }
    }


    private void toSubmitReply() {
        try {
            if (mEdtCmt.getText().toString().trim().length() > 0) {
//                MyPost.toReplyOnComment(getContext(), commentId, mEdtCmt.getText().toString().trim());
                toDisplayReply();
                mEdtCmt.setText("");
            } else {
                CommonFunctions.toDisplayToast("Empty", getContext());
            }
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);

        }
    }

    public void toDisplayReply() {
        try {
            final View view = LayoutInflater.from(getContext()).inflate(R.layout.rv_layout, null, false);
            if (view != null) {
                VolleySingleton.getInstance(getContext())
                        .addToRequestQueue(
                                new StringRequest(Request.Method.POST,
                                        AppConstants.URL + getContext().getString(R.string.str_like_share_comment) + getContext().getString(R.string.str_php),
                                        new Response.Listener<String>() {

                                            @Override
                                            public void onResponse(String res) {
                                                try {
                                                    if (res != null && res.length() > 0) {
                                                        Log.d("HmApp", "Reply Res " + res);
                                                        JSONArray array = new JSONArray(res);
                                                        if (array != null) {
                                                            if (array.length() > 0) {
                                                                LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                                                                params.setMargins(80, 0, 0, 0);
                                                                mRv.setLayoutParams(params);
                                                                mRv.setLayoutManager(new LinearLayoutManager(getContext()));
                                                                mRv.hasFixedSize();
                                                                mRv.setNestedScrollingEnabled(false);
                                                                mRv.setAdapter(new DisplayReplyAdapter(getContext(), array));
                                                            } else {
                                                                CommonFunctions.toDisplayToast("No Reply", getContext());
                                                            }
                                                        } else {
                                                            CommonFunctions.toDisplayToast("No Reply", getContext());
                                                        }
                                                    } else {
                                                        CommonFunctions.toDisplayToast("No Reply", getContext());
                                                    }
                                                } catch (Exception | Error e) {
                                                    e.printStackTrace();
                                                    Crashlytics.logException(e);
                                                }
                                            }
                                        },
                                        new Response.ErrorListener() {
                                            @Override
                                            public void onErrorResponse(VolleyError error) {
                                                error.printStackTrace();
                                            }
                                        }
                                ) {
                                    @Override
                                    protected Map<String, String> getParams() {
                                        Map<String, String> params = new HashMap<String, String>();
                                        params.put(getContext().getString(R.string.str_action_), getContext().getString(R.string.str_fetch_reply_comment_));
                                        params.put(getContext().getString(R.string.str_comment_id), commentId);
                                        return params;
                                    }
                                }
                                , getContext().getString(R.string.str_fetch_reply_comment_));
            }
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);

        }
    }
}<file_sep>package com.hm.application.utils.insta.utils;

import android.os.Environment;

public class FilePaths {

    //"storage/emulated/0"
    public String ROOT_DIR = Environment.getExternalStorageDirectory().getPath();

    public String PICTURES = ROOT_DIR + "/Pictures";
    public String DOWNLOADS = ROOT_DIR + "/Downloads";
    public String MAIN = ROOT_DIR + "/";
    public String DICM_CAMERA = ROOT_DIR + "/DCIM/camera";
    public String CAMERA = ROOT_DIR + "/Camera";
    public String STORIES = ROOT_DIR + "/Stories";

    public String FIREBASE_STORY_STORAGE = "stories/users";
    public String FIREBASE_IMAGE_STORAGE = "photos/users/";

}
<file_sep>package com.hm.application.fragments;


import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TextInputEditText;
import android.support.design.widget.TextInputLayout;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.crashlytics.android.Crashlytics;
import com.hm.application.R;
import com.hm.application.activity.AccountSettingsActivity;
import com.hm.application.model.AppConstants;
import com.hm.application.model.User;
import com.hm.application.network.VolleySingleton;
import com.hm.application.utils.CommonFunctions;
import com.hm.application.utils.HmFonts;
import com.hm.application.utils.KeyBoard;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class ChangePasswordFragment extends Fragment {

    LinearLayout mLlChangePwdMain, mLlChangePwd, mLlChangePwdEdit;
    TextInputLayout mTilCurrentPwd, mTilNewPwd, mTilConfirmPwd;
    TextInputEditText mEdtCurrentPwd, mEdtNewPwd, mEdtConfirmPwd;
    ImageView mIvChangePwdCancel;
    TextView mTvLblChangePwd;
    Button mBtnSubmit;

    public ChangePasswordFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_change_password, container, false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        dataBinding();
    }

    private void dataBinding() {
        try {
            mIvChangePwdCancel = getActivity().findViewById(R.id.imgChangePwdCancel);

            mBtnSubmit = getActivity().findViewById(R.id.btnSubmit);

            mTvLblChangePwd = getActivity().findViewById(R.id.txtLblChangePwd);
            mTvLblChangePwd.setTypeface(HmFonts.getRobotoBold(getContext()));

            mLlChangePwdMain = getActivity().findViewById(R.id.llChangePwdMain);
            mLlChangePwd = getActivity().findViewById(R.id.llChangePwd);
            mLlChangePwdEdit = getActivity().findViewById(R.id.llChangePwdEdit);

            mEdtCurrentPwd = getActivity().findViewById(R.id.edtCurrentPwd);
            mEdtCurrentPwd.setTypeface(HmFonts.getRobotoRegular(getContext()));

            mEdtNewPwd = getActivity().findViewById(R.id.edtNewPwd);
            mEdtNewPwd.setTypeface(HmFonts.getRobotoRegular(getContext()));

            mEdtConfirmPwd = getActivity().findViewById(R.id.edtConfirmPwd);
            mEdtConfirmPwd.setTypeface(HmFonts.getRobotoRegular(getContext()));

            mTilCurrentPwd = getActivity().findViewById(R.id.mTilCurrentPwd);
            mTilCurrentPwd.setTypeface(HmFonts.getRobotoRegular(getContext()));

            mTilNewPwd = getActivity().findViewById(R.id.mTilNewPwd);
            mTilNewPwd.setTypeface(HmFonts.getRobotoRegular(getContext()));

            mTilConfirmPwd = getActivity().findViewById(R.id.mTilConfirmPwd);
            mTilConfirmPwd.setTypeface(HmFonts.getRobotoRegular(getContext()));

            mIvChangePwdCancel.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    getActivity().getSupportFragmentManager().beginTransaction().remove(ChangePasswordFragment.this).commit();
                }
            });

            mBtnSubmit.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    KeyBoard.hideKeyboard(getActivity());
                    toSetNewPassword();
                }
            });

            mEdtCurrentPwd.setOnEditorActionListener(new EditText.OnEditorActionListener() {
                @Override
                public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                    if (actionId == EditorInfo.IME_ACTION_NEXT) {
                        if (isValidCurrentPassword()) {
                            mEdtNewPwd.requestFocus();
                            return true;
                        } else {
                            mEdtCurrentPwd.requestFocus();
                            return false;
                        }
                    } else {
                        return false;
                    }
                }

            });

            mEdtNewPwd.setOnEditorActionListener(new EditText.OnEditorActionListener() {
                @Override
                public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                    if (actionId == EditorInfo.IME_ACTION_NEXT) {
                        if (isValidNewPassword()) {
                            mEdtConfirmPwd.requestFocus();
                            return true;
                        } else {
                            mEdtNewPwd.requestFocus();
                            return false;
                        }
                    } else {
                        return false;
                    }
                }
            });

            mEdtConfirmPwd.setOnEditorActionListener(new EditText.OnEditorActionListener() {
                @Override
                public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                    if (actionId == EditorInfo.IME_ACTION_NEXT) {
                        if (isValidCnfPassword()) {
                            mBtnSubmit.requestFocus();
                            return true;
                        } else {
                            mEdtConfirmPwd.requestFocus();
                            return false;
                        }
                    } else {
                        return false;
                    }
                }
            });

            mEdtCurrentPwd.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {
                    isValidCurrentPassword();
                }

                @Override
                public void afterTextChanged(Editable s) {
                    isValidCurrentPassword();
                }
            });

            mEdtNewPwd.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {
                    isValidNewPassword();
                }

                @Override
                public void afterTextChanged(Editable s) {
                    isValidNewPassword();
                }
            });

            mEdtConfirmPwd.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {
                    isValidCnfPassword();
                }

                @Override
                public void afterTextChanged(Editable s) {
                    isValidCnfPassword();
                }
            });

        } catch (Exception | Error e) {
            e.printStackTrace(); Crashlytics.logException(e);

        }
    }

    public boolean isValidCurrentPassword() {
        if (mEdtCurrentPwd.getText().toString().trim().length() == 0) {
            mTilCurrentPwd.setError(getString(R.string.str_field_cant_be_empty));
            return false;
        } else if (mEdtCurrentPwd.getText().toString().trim().length() < 8) {
            mTilCurrentPwd.setError(getString(R.string.str_error_minimum_8));
            return false;
        } else if (mEdtCurrentPwd.getText().toString().trim().length() > 15) {
            mTilCurrentPwd.setError(getString(R.string.str_error_maximum_15));
            return false;
        } else if (CommonFunctions.isValidPassword(mEdtCurrentPwd.getText().toString().trim())) {
            mTilCurrentPwd.setError(getString(R.string.str_error_pswd));
            return false;
        } else {
            mTilCurrentPwd.setError(null);
            return true;
        }
    }

    public boolean isValidNewPassword() {
        if (mEdtNewPwd.getText().toString().trim().length() == 0) {
            mTilNewPwd.setError(getString(R.string.str_field_cant_be_empty));
            return false;
        } else if (mEdtNewPwd.getText().toString().trim().length() < 8) {
            mTilNewPwd.setError(getString(R.string.str_error_minimum_8));
            return false;
        } else if (mEdtNewPwd.getText().toString().trim().length() > 15) {
            mTilNewPwd.setError(getString(R.string.str_error_maximum_15));
            return false;
        } else if (CommonFunctions.isValidPassword(mEdtNewPwd.getText().toString().trim())) {
            mTilNewPwd.setError(getString(R.string.str_error_pswd));
            return false;
        } else {
            mTilNewPwd.setError(null);
            return true;
        }
    }

    public boolean isValidCnfPassword() {
        if (mEdtConfirmPwd.getText().toString().trim().length() == 0) {
            mTilConfirmPwd.setError(getString(R.string.str_field_cant_be_empty));
            return false;
        } else if (mEdtConfirmPwd.getText().toString().trim().length() < 8) {
            mTilConfirmPwd.setError(getString(R.string.str_error_minimum_8));
            return false;
        } else if (mEdtConfirmPwd.getText().toString().trim().length() > 15) {
            mTilConfirmPwd.setError(getString(R.string.str_error_maximum_15));
            return false;
        } else if (CommonFunctions.isValidPassword(mEdtConfirmPwd.getText().toString().trim())) {
            mTilConfirmPwd.setError(getString(R.string.str_error_pswd));
            return false;
        } else {
            mTilConfirmPwd.setError(null);
            return true;
        }
    }

    public void toSetNewPassword(){
        String oldPwd = mEdtCurrentPwd.getText().toString().trim();
        String newPwd = mEdtNewPwd.getText().toString().trim();
        String cnfPwd = mEdtConfirmPwd.getText().toString().trim();

        if (!oldPwd.equals(newPwd)){
            if (newPwd.equals(cnfPwd)){
                toChangePassword(getContext());
            }else {
                mTilConfirmPwd.setError("Invalid password");
                mTilNewPwd.setError("Invalid Password");
                CommonFunctions.toDisplayToast("Password Don't Match !",getContext());
            }
        }else {
            mTilCurrentPwd.setError("Invalid Password");
            mTilNewPwd.setError("Invalid Password");
            CommonFunctions.toDisplayToast("Current Password is Incorrect!",getContext());
        }
    }

    public  void toChangePassword(final Context context) {
        try {
            CommonFunctions.toCallLoader(context, "Loading");
            VolleySingleton.getInstance(context)
                    .addToRequestQueue(
                            new StringRequest(
                                    Request.Method.POST,
                                    AppConstants.URL + context.getResources().getString(R.string.str_register_login) + context.getResources().getString(R.string.str_php),
                                    new Response.Listener<String>() {
                                        @Override
                                        public void onResponse(String res) {
                                            try {
                                                CommonFunctions.toCloseLoader();
                                                Log.d("HmApp", " Change Password: " + res);
                                                if (res != null) {
                                                    JSONObject response = new JSONObject(res.trim());
                                                    if (response != null) {
                                                        Log.d("HmApp", "Change Password123:" + response);
                                                        if (!response.isNull("status")) {
                                                            if (response.getInt("status") == 0) {
                                                                CommonFunctions.toDisplayToast("Unable to Change Password", context);
                                                            } else if (response.getInt("status") == 1) {
                                                                CommonFunctions.toDisplayToast("Password Change Successfully", context);
                                                                getActivity().getSupportFragmentManager().beginTransaction().remove(ChangePasswordFragment.this).commit();
                                                            }
                                                        }
                                                    } else {
                                                        CommonFunctions.toDisplayToast("Unable to Change Password", context);
                                                    }
                                                } else {
                                                    CommonFunctions.toDisplayToast("Unable to Change Password", context);
                                                }
                                            } catch (Exception | Error e) {
                                                e.printStackTrace();
                                                Crashlytics.logException(e);
                                                CommonFunctions.toCloseLoader();
                                            }
                                        }
                                    },
                                    new Response.ErrorListener() {
                                        @Override
                                        public void onErrorResponse(VolleyError error) {
                                            error.printStackTrace();
                                            CommonFunctions.toCloseLoader();
                                            CommonFunctions.toDisplayToast("Unable to  Change Password", context);
                                        }
                                    }
                            ) {
                                @Override
                                protected Map<String, String> getParams() {
                                    Map<String, String> params = new HashMap<String, String>();
                                    params.put(context.getResources().getString(R.string.str_action_), context.getString(R.string.str_change_password_));
                                    params.put(context.getString(R.string.str_uid), User.getUser(context).getUid());
                                    params.put(context.getResources().getString(R.string.str_old_password),mEdtCurrentPwd.getText().toString().trim());
                                    params.put(context.getResources().getString(R.string.str_new_password_), mEdtNewPwd.getText().toString().trim());
                                    return params;
                                }
                            }
                            , context.getString(R.string.str_change_password_));
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);
            CommonFunctions.toCloseLoader();
        }
    }
}
<file_sep>package com.hm.application.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.design.widget.TabLayout;
import android.support.v4.view.PagerAdapter;
import android.util.Log;
import android.view.GestureDetector;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.crashlytics.android.Crashlytics;
import com.hm.application.R;
import com.hm.application.common.MyPost;
import com.hm.application.fragments.UserTab1Fragment;
import com.hm.application.model.AppConstants;
import com.squareup.picasso.Picasso;

public class SlidingImageAdapter extends PagerAdapter {

    private String[] images;
    private String pos;
    private Context context;
    private TabLayout tabLayout;
    private boolean status;
    private UserTab1Fragment userTab1Fragment;

    public SlidingImageAdapter(Context ctx, String[] img, String position, UserTab1Fragment userTab1Frg, TabLayout mTl) {
        context = ctx;
        images = img;
        pos = position;
        tabLayout = mTl;
        userTab1Fragment = userTab1Frg;
    }

    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
        container.removeView((View) object);
    }

    @Override
    public int getCount() {
        return images.length;
    }

    @SuppressLint("ClickableViewAccessibility")
    @NonNull
    @Override
    public Object instantiateItem(@NonNull ViewGroup view, final int position) {
        try {
            Log.d("Hmapp", "images " + images[position]);
            View inflate = LayoutInflater.from(context).inflate(R.layout.single_image_view, view, false);
            ImageView imageView = inflate.findViewById(R.id.image_single);
            Picasso.with(context)
                    .load(AppConstants.URL + images[position].trim().replace("\\s", "%20"))
                    .into(imageView);
            view.addView(inflate, 0);

//            imageView.setOnClickListener(new View.OnClickListener() {
////                @Override
////                public void onClick(View v) {
////                    if (userTab1Fragment != null) {
////                        userTab1Fragment.toCallSinglePostData(Integer.parseInt(pos), "Multiple");
////                    }
////                }
////            });
            if (images.length > 1) {
                tabLayout.setVisibility(View.VISIBLE);
            } else {
                tabLayout.setVisibility(View.GONE);
            }
            return inflate;
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);
        }
        return null;
    }

    @Override
    public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
        return view.equals(object);
    }
}<file_sep>package com.hm.application.fragments;

import android.content.Context;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.crashlytics.android.Crashlytics;
import com.hm.application.R;
import com.hm.application.adapter.NotificationAdapter;
import com.hm.application.model.AppConstants;
import com.hm.application.model.User;
import com.hm.application.network.VolleySingleton;
import com.hm.application.utils.CommonFunctions;
import com.hm.application.utils.HmFonts;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;


public class NotificationYouFragment extends Fragment {
    Bundle bundle;
    private RecyclerView mRvNfMain;
    private RelativeLayout mRlFollowRequest;
    private TextView mTvNfFollow, mTvNfYou, mTvFollowRequest, mTvFollow;
    private OnFragmentInteractionListener mListener;
    private String timelineId = null;
    private JSONObject obj;

    public NotificationYouFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_notification_you, container, false);

    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        checkInternetConnection();
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        if (context instanceof OnFragmentInteractionListener) {
            mListener = (OnFragmentInteractionListener) context;
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
        mListener = null;
    }

    private void checkInternetConnection() {
        try {
            if (CommonFunctions.isOnline(getContext())) {
                new toGetNotification().execute();
                mTvNfYou = getActivity().findViewById(R.id.tvNfYou);
                mTvNfYou.setTypeface(HmFonts.getRobotoBold(getContext()));

                mTvFollowRequest = getActivity().findViewById(R.id.tvFollowRequest);
                mTvFollowRequest.setTypeface(HmFonts.getRobotoBold(getContext()));

                mTvFollow = getActivity().findViewById(R.id.tvFollow);
                mTvFollow.setTypeface(HmFonts.getRobotoRegular(getContext()));

                mRlFollowRequest = getActivity().findViewById(R.id.rlFollowRequest);
                mRlFollowRequest.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Main_FriendRequestFragment main = new Main_FriendRequestFragment();
                        getActivity()
                                .getSupportFragmentManager()
                                .beginTransaction()
                                .add(R.id.flHomeContainer, main)
                                .addToBackStack(main.getClass().getName())
                                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
                                .commit();
                    }
                });
            } else {
                CommonFunctions.toDisplayToast(getResources().getString(R.string.lbl_no_check_internet), getContext());
            }
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);

        }
    }

    public interface OnFragmentInteractionListener {
        void onFragmentInteraction(Uri uri);
    }

    private class toGetNotification extends AsyncTask<Void, Void, Void> {
        @Override
        protected Void doInBackground(Void... voids) {
            try {
                VolleySingleton.getInstance(getContext())
                        .addToRequestQueue(
                                new StringRequest(Request.Method.POST,
                                        AppConstants.URL + getString(R.string.str_notification_uid) + getContext().getResources().getString(R.string.str_php),
                                        new Response.Listener<String>() {

                                            @Override
                                            public void onResponse(String res) {
                                                Log.d("HmApp", "notification:" + res);
                                                try {
                                                    if (res != null && res.length() > 0) {
                                                        JSONArray array = new JSONArray(res.trim());
                                                        if (array != null) {
                                                            if (array.length() > 0) {
                                                                mRvNfMain = getActivity().findViewById(R.id.rvNfYou);
                                                                LinearLayoutManager llm = new LinearLayoutManager(getContext());
                                                                llm.setReverseLayout(true);
                                                                mRvNfMain.setLayoutManager(llm);
                                                                mRvNfMain.hasFixedSize();
                                                                mRvNfMain.setAdapter(new NotificationAdapter(getContext(), array));

                                                            } else {
                                                                CommonFunctions.toDisplayToast("No Data Found", getContext());
                                                            }
                                                        } else {
                                                            CommonFunctions.toDisplayToast("No Data Found", getContext());

                                                        }
                                                    } else {
                                                        CommonFunctions.toDisplayToast("No Data Found", getContext());

                                                    }
                                                } catch (Exception | Error e) {
                                                    e.printStackTrace();
                                                    Crashlytics.logException(e);

                                                }
                                            }
                                        },
                                        new Response.ErrorListener() {
                                            @Override
                                            public void onErrorResponse(VolleyError error) {
                                                error.printStackTrace();
                                            }
                                        }
                                ) {
                                    @Override
                                    protected Map<String, String> getParams() {
                                        Map<String, String> params = new HashMap<String, String>();
                                        params.put(getString(R.string.str_action_), getString(R.string.str_list_notification));
                                        params.put(getString(R.string.str_uid), User.getUser(getContext()).getUid());
                                        return params;
                                    }
                                }
                                , getContext().getString(R.string.str_sent_notification));
            } catch (Exception | Error e) {
                e.printStackTrace();
                Crashlytics.logException(e);
            }
            return null;
        }
    }
}

<file_sep>package com.hm.application.services;

import android.util.Log;

import com.crashlytics.android.Crashlytics;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;
import com.hm.application.model.AppDataStorage;
import com.hm.application.model.User;

import java.util.zip.CRC32;

public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {

    @Override
    public void onTokenRefresh() {
        try {
            // Get updated InstanceID token.
            String refreshedToken = FirebaseInstanceId.getInstance().getToken();
            // If you want to send messages to this application instance or
            // manage this apps subscriptions on the server side, send the
            // Instance ID token to your app server.
            Log.d("HmApp", "Refreshed token: " + refreshedToken);
            User.getUser(this).setFcmToken(refreshedToken);
            AppDataStorage.setUserInfo(this);
        } catch (Exception| Error e){
            e.printStackTrace();
            Crashlytics.logException(e);
        }
    }
}<file_sep>package com.hm.application.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.crashlytics.android.Crashlytics;
import com.hm.application.R;
import com.hm.application.activity.SinglePostDataActivity;
import com.hm.application.model.AppConstants;
import com.squareup.picasso.Picasso;

import org.json.JSONArray;

public class UserTab21Adapter extends RecyclerView.Adapter<UserTab21Adapter.ViewHolder> {

    private Context context;
    private JSONArray array;

    public UserTab21Adapter(Context ctx, JSONArray data) {
        context = ctx;
        array = data;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder(LayoutInflater.from(context).inflate(R.layout.album_layout, parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        try {
            if (!array.getJSONObject(position).isNull(context.getString(R.string.str_image_url))) {
                Picasso.with(context)
                        .load(AppConstants.URL + array.getJSONObject(position).getString(context.getString(R.string.str_image_url)).replaceAll("\\s", "%20"))
                        .error(R.color.light2)
                        .placeholder(R.color.light)
                        .into(holder.mImgActPic);
            } else {
                holder.mImgActPic.setBackgroundColor(ContextCompat.getColor(context, R.color.light2));
            }
        } catch (Exception | Error e) {
            e.printStackTrace(); Crashlytics.logException(e);

        }
    }

    @Override
    public int getItemCount() {
        return array == null ? 0 : array.length();
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        private ImageView mImgActPic;
        private TextView mTxtAlbumName;

        ViewHolder(View itemView) {
            super(itemView);
            mTxtAlbumName = itemView.findViewById(R.id.txtAlbumName);
            mTxtAlbumName.setVisibility(View.GONE);
            mImgActPic = itemView.findViewById(R.id.imgAlbumPic);
            mImgActPic.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    try {
                        context.startActivity(
                                new Intent(context, SinglePostDataActivity.class)
                                        .putExtra(AppConstants.FROM, "Single")
                                        .putExtra(AppConstants.BUNDLE, array.getJSONObject(getAdapterPosition()).toString()));
                    } catch (Exception | Error e) {
                        e.printStackTrace(); Crashlytics.logException(e);

                    }
                }
            });
        }
    }
}<file_sep>package com.hm.application.classes;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.crashlytics.android.Crashlytics;
import com.hm.application.R;
import com.hm.application.adapter.CommentsAdapter;
import com.hm.application.adapter.DisplayReplyAdapter;
import com.hm.application.model.AppConstants;
import com.hm.application.network.VolleySingleton;
import com.hm.application.utils.CommonFunctions;

import org.json.JSONArray;

import java.util.HashMap;
import java.util.Map;

public class Post {

    static RecyclerView mRvCmt;
    static LinearLayout mLlAddCmt;
    static Context context;
    static String timelineId;

    public static void toDisplayComments(String timelineId_, RecyclerView mRvCmt_, Context context_, LinearLayout mLlAddCmt_) {
        timelineId = timelineId_;
        mRvCmt = mRvCmt_;
        mLlAddCmt = mLlAddCmt_;
        context = context_;
        toDisplayComments();
    }

    private static void toDisplayComments() {// extends AsyncTask<Void, Void, Void> {
//        @Override
//        protected Void doInBackground(Void... voids) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    VolleySingleton.getInstance(context)
                            .addToRequestQueue(
                                    new StringRequest(Request.Method.POST,
                                            AppConstants.URL + context.getString(R.string.str_like_share_comment) + context.getString(R.string.str_php),
                                            new Response.Listener<String>() {

                                                @Override
                                                public void onResponse(String res) {
                                                    try {
                                                        if (res != null && res.length()>0) {
                                                            Log.d("HmApp", "Comment Res: " + res);
                                                            JSONArray array = new JSONArray(res.trim());
                                                            if (array.length() > 0) {
                                                                if (mLlAddCmt.getChildCount() > 0) {
                                                                    mLlAddCmt.removeAllViews();
                                                                }
                                                                LinearLayoutManager llm = new LinearLayoutManager(context);
//                                                            llm.setReverseLayout(true);
//                                                        llm.setStackFromEnd(true);
                                                                mRvCmt.setLayoutManager(llm);
                                                                mRvCmt.hasFixedSize();
                                                                mRvCmt.setVisibility(View.VISIBLE);
                                                                mRvCmt.setNestedScrollingEnabled(false);
                                                                mRvCmt.setAdapter(new CommentsAdapter(context, array));
//                                                        mRvCmt.smoothScrollToPosition(array.length() - 1);

                                                            } else {
                                                                CommonFunctions.toDisplayToast("No Comment", context);
                                                            }
                                                        } else {
                                                         CommonFunctions.toDisplayToast("No Comment", context);
                                                        }
                                                    } catch (Exception | Error e) {
                                                        e.printStackTrace(); Crashlytics.logException(e);

                                                    }
                                                }
                                            },
                                            new Response.ErrorListener() {
                                                @Override
                                                public void onErrorResponse(VolleyError error) {
                                                    error.printStackTrace();
                                                }
                                            }
                                    ) {
                                        @Override
                                        protected Map<String, String> getParams() {
                                            Map<String, String> params = new HashMap<>();
                                            params.put(context.getString(R.string.str_action_), context.getString(R.string.str_fetch_comment_));
                                            params.put(context.getString(R.string.str_timeline_id_), timelineId);
//                                        params.put(context.getString(R.string.str_timeline_id_), "102");
                                            Log.d("hmapp", " comment fragment_timeline Api:" + timelineId);
                                            return params;
                                        }
                                    }
                                    , context.getString(R.string.str_fetch_comment_));
                } catch (Exception | Error e) {
                    e.printStackTrace(); Crashlytics.logException(e);

                }
            }
        }).start();
//            return null;
//        }
    }

    public static void toDisplayReply(final String id, LinearLayout mLlCuReply, final Context context) {
        try {
            if (mLlCuReply.getChildCount() > 0) {
                mLlCuReply.removeAllViews();
            }
            final View view = LayoutInflater.from(context).inflate(R.layout.rv_layout, null, false);
            if (view != null) {
                VolleySingleton.getInstance(context)
                        .addToRequestQueue(
                                new StringRequest(Request.Method.POST,
                                        AppConstants.URL + context.getString(R.string.str_like_share_comment) + context.getString(R.string.str_php),
                                        new Response.Listener<String>() {

                                            @Override
                                            public void onResponse(String res) {
                                                try {
                                                    if (res != null && res.trim().length()>0){
                                                    Log.d("HmApp", "Reply Res " + res);
                                                    JSONArray array = new JSONArray(res);
                                                    if (array != null) {
                                                        if (array.length() > 0) {
                                                            RecyclerView mRv = view.findViewById(R.id.mRvCommon);
                                                            mRv.setLayoutManager(new LinearLayoutManager(context));
                                                            mRv.hasFixedSize();
                                                            mRv.setNestedScrollingEnabled(false);
                                                            mRv.setAdapter(new DisplayReplyAdapter(context, array));
                                                        } else {
                                                            CommonFunctions.toDisplayToast("No Reply", context);
                                                        }
                                                    } else {
                                                        CommonFunctions.toDisplayToast("No Reply", context);
                                                    }
                                                } else {
                                                        CommonFunctions.toDisplayToast("No Reply", context);
                                                    }
                                                } catch (Exception | Error e) {
                                                    e.printStackTrace(); Crashlytics.logException(e);

                                                }
                                            }
                                        },
                                        new Response.ErrorListener() {
                                            @Override
                                            public void onErrorResponse(VolleyError error) {
                                                error.printStackTrace();
                                            }
                                        }
                                ) {
                                    @Override
                                    protected Map<String, String> getParams() {
                                        Map<String, String> params = new HashMap<String, String>();
                                        params.put(context.getString(R.string.str_action_), context.getString(R.string.str_fetch_reply_comment_));
                                        params.put(context.getString(R.string.str_comment_id), id);
                                        return params;
                                    }
                                }
                                , context.getString(R.string.str_fetch_reply_comment_));
                mLlCuReply.addView(view);
            }
        } catch (Exception | Error e) {
            e.printStackTrace(); Crashlytics.logException(e);

        }
    }
}<file_sep>package com.hm.application.fragments;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.provider.MediaStore.MediaColumns;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.crashlytics.android.Crashlytics;
import com.hm.application.R;
import com.hm.application.activity.NextActivity;
import com.hm.application.model.AppConstants;
import com.hm.application.utils.CommonFunctions;
import com.hm.application.utils.insta.utils.SquareImageView;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;

import java.util.ArrayList;

public class GalleryFragment extends Fragment {

    private GridView mGridView;
    private ImageView mIvSelectImage;
    private TextView mTvNextScreen;
    private ArrayList<String> mMultiSelectImages, mAllImages;

    private OnFragmentInteractionListener mListener;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        if (context instanceof OnFragmentInteractionListener) {
            mListener = (OnFragmentInteractionListener) context;
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
        mListener = null;
    }

    public interface OnFragmentInteractionListener {
        void onFragmentInteraction(Uri uri);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = null;
        try {
            view = inflater.inflate(R.layout.fragment_gallery, container, false);
            mIvSelectImage = view.findViewById(R.id.galleryImageView);
            mGridView = view.findViewById(R.id.gridViewGallery);
            mMultiSelectImages = new ArrayList<>();
            mAllImages = new ArrayList<>();
            mTvNextScreen = view.findViewById(R.id.tvNext);
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);
        }
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        try {
            mAllImages = getImagesPath(getActivity());

            int gridWidth = getResources().getDisplayMetrics().widthPixels;
            int imageWidth = gridWidth / 3;
            mGridView.setColumnWidth(imageWidth);

            mTvNextScreen.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mMultiSelectImages.size() == 0) {
                        CommonFunctions.toDisplayToast("Please select at least one image", getContext());
                    } else {
                        if (mMultiSelectImages.size() > 1) {
                            CommonFunctions.toDisplayToast("You've selected Total " + mMultiSelectImages.size() + " image(s).", getContext());
                        }
                        Intent intent = new Intent(getActivity(), NextActivity.class);
//                        intent.putExtra(getString(R.string.selected_image), mSelectedImage);
                        intent.putExtra("list", mMultiSelectImages);
                        startActivity(intent);
                    }
                }
            });

            if (mAllImages != null && mAllImages.size() > 0) {
                mGridView.setAdapter(new GridImageAdapter(getContext(), R.layout.layout_grid_imageview, mAllImages));
                setImage(mAllImages.get(0), mIvSelectImage, AppConstants.Append);
            } else {
                CommonFunctions.toDisplayToast(" No Images ", getContext());
            }

            mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    setImage(mAllImages.get(position), mIvSelectImage, AppConstants.Append);
                }
            });
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);

        }
    }

    public static ArrayList<String> getImagesPath(Activity activity) {
        Uri uri;
        ArrayList<String> listOfAllImages = new ArrayList<String>();
        Cursor cursor;
        int column_index_data;
        String PathOfImage = null;
        uri = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;

        String[] projection = {MediaColumns.DATA,
                MediaStore.Images.Media.BUCKET_DISPLAY_NAME};

        cursor = activity.getContentResolver().query(uri, projection, null,
                null, null);

        column_index_data = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
        while (cursor.moveToNext()) {
            PathOfImage = cursor.getString(column_index_data);
            listOfAllImages.add(PathOfImage);
        }
        return listOfAllImages;
    }

    private void setImage(String imgURL, ImageView image, String append) {
        ImageLoader imageLoader = ImageLoader.getInstance();
        imageLoader.init(ImageLoaderConfiguration.createDefault(getContext()));

        imageLoader.displayImage(append + imgURL, image, new ImageLoadingListener() {
            @Override
            public void onLoadingStarted(String imageUri, View view) {
            }

            @Override
            public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
            }

            @Override
            public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            }

            @Override
            public void onLoadingCancelled(String imageUri, View view) {
            }
        });
    }


    public class GridImageAdapter extends ArrayAdapter<String> {

        private Context context;
        private int layoutResource;
        private ArrayList<String> imgURLs;

        public GridImageAdapter(Context context, int layoutResource, ArrayList<String> imgURLs) {
            super(context, layoutResource, imgURLs);
            this.context = context;
            this.layoutResource = layoutResource;
            this.imgURLs = imgURLs;
        }

        private class ViewHolder {
            SquareImageView image;
            CheckBox checkbox;
            RelativeLayout relativeLayout;
            int id;
        }

        @NonNull
        @Override
        public View getView(final int position, @Nullable View row, @NonNull ViewGroup parent) {
            final ViewHolder holder;
            View convertView = row;
            if (convertView == null) {
                LayoutInflater inflater = ((Activity) context).getLayoutInflater();
                convertView = inflater.inflate(layoutResource, parent, false);
                holder = new ViewHolder();
                holder.image = convertView.findViewById(R.id.gridImageView);
                holder.checkbox = convertView.findViewById(R.id.itemCheckBox);
                holder.relativeLayout = convertView.findViewById(R.id.rl1);
                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }

            holder.checkbox.setId(position);
            holder.relativeLayout.setId(position);
            holder.image.setId(position);
            holder.relativeLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    int id = v.getId();
                    if (holder.checkbox.isChecked()) {
                        holder.checkbox.setChecked(false);
                        if (mMultiSelectImages != null) {
                            mMultiSelectImages.remove(getItem(id));
                        }
                    } else {
                        holder.checkbox.setChecked(true);
                        if (mMultiSelectImages != null) {
                            mMultiSelectImages.add(getItem(id));
                        }
                        setImage(getItem(id), mIvSelectImage, AppConstants.Append);
                    }
                }
            });
            holder.checkbox.setOnClickListener(new View.OnClickListener() {

                public void onClick(View v) {
                    toSetView(v);
                }
            });
            ImageLoader imageLoader = ImageLoader.getInstance();
            imageLoader.init(ImageLoaderConfiguration.createDefault(getContext()));

            imageLoader.displayImage(AppConstants.Append + getItem(position), holder.image, new ImageLoadingListener() {
                @Override
                public void onLoadingStarted(String imageUri, View view) {
                }

                @Override
                public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
                }

                @Override
                public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                }

                @Override
                public void onLoadingCancelled(String imageUri, View view) {
                }
            });
            holder.checkbox.setChecked(mMultiSelectImages.contains(getItem(position)));
            return convertView;
        }

        private void toSetView(View v) {
            CheckBox cb = (CheckBox) v;
            int id = cb.getId();
            if (mMultiSelectImages.contains(getItem(id))) {
                cb.setChecked(false);
                if (mMultiSelectImages != null) {
                    mMultiSelectImages.remove(getItem(id));
                }
            } else {
                cb.setChecked(true);
                if (mMultiSelectImages != null) {
                    mMultiSelectImages.add(getItem(id));
                }
                setImage(getItem(id), mIvSelectImage, AppConstants.Append);
            }
        }
    }
}<file_sep>apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.firebase.firebase-perf'

android {
    useLibrary 'org.apache.http.legacy'
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.hm.application"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:gridlayout-v7:27.1.1'
    implementation 'com.android.support:mediarouter-v7:27.1.1'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.volley:volley:1.1.0'

    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.2'

    implementation 'com.google.android.gms:play-services-analytics:15.0.2'
    implementation 'com.google.android.gms:play-services-gcm:15.0.1'
    implementation 'com.google.android.gms:play-services-location:15.0.1'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.google.android.gms:play-services-places:15.0.1'
    implementation 'com.google.android.exoplayer:exoplayer:2.6.0'
    implementation 'com.google.code.gson:gson:2.8.0'

    implementation 'com.google.firebase:firebase-messaging:15.0.2'
    implementation 'com.google.firebase:firebase-perf:15.1.0'

    implementation 'com.github.ittianyu:BottomNavigationViewEx:1.1.9'
    implementation 'com.github.eschao:android-ElasticListView:v1.0'
    implementation 'com.github.bumptech.glide:glide:4.4.0'
    implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
    implementation 'com.android.support:exifinterface:27.1.1'
    implementation 'com.felipecsl.asymmetricgridview:library:2.0.1'

    implementation 'com.squareup.picasso:picasso:2.5.2'

    implementation 'de.hdodenhof:circleimageview:2.2.0'

    implementation 'org.apache.httpcomponents:httpcore:4.3.2'
    implementation 'org.apache.httpcomponents:httpmime:4.3'

    implementation 'nl.psdcompany:duo-navigation-drawer:2.0.5'

    implementation files('libs/aspectjrt-1.7.3 (1).jar')
    implementation files('libs/aspectjrt-1.7.3 (1).jar')

    annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'

    testImplementation 'junit:junit:4.12'

    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
<file_sep>package com.hm.application.fragments;

import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.crashlytics.android.Crashlytics;
import com.hm.application.R;
import com.hm.application.model.AppConstants;
import com.hm.application.utils.CommonFunctions;

public class UserTab2Fragment extends Fragment {

    Bundle bundle;
    private TabLayout tabLayout;
    private OnFragmentInteractionListener mListener;

    public UserTab2Fragment() {
        // Required empty public constructor
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        if (context instanceof OnFragmentInteractionListener) {
            mListener = (OnFragmentInteractionListener) context;
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
        mListener = null;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_user_tab2, container, false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        checkInternetConnection();

        tabLayout = getActivity().findViewById(R.id.tbUsersTab2);
        replacePage(new UserTab21Fragment());
        tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                switch (tab.getPosition()) {
                    case 0:
                        replacePage(new UserTab21Fragment());
                        break;
                    case 1:
                        replacePage(new UserTab22Fragment());
                        break;
                    case 2:
                        replacePage(new UserTab23Fragment());
                        break;
                    case 3:
                        replacePage(new UserTab24Fragment());
                        break;
                    default:
                        replacePage(new UserTab21Fragment());
                        break;
                }
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
    }

    private void checkInternetConnection() {
        try {
            if (CommonFunctions.isOnline(getContext())) {
                Log.d("HmApp", "  agr fetch_timeline 1 " + getArguments());
                if (getArguments() != null) {
                    bundle = new Bundle();
                    Log.d("HmApp", " agr2 " + getArguments().getBoolean("other_user"));
                    bundle.putBoolean("other_user2", getArguments().getBoolean("other_user"));
                    bundle.putString(AppConstants.F_UID, getArguments().getString("F_UID"));
                    bundle.putString("fetch_photos2", getArguments().getString("fetch_photos"));
                    bundle.putString("fetch_albums2", getArguments().getString("fetch_albums"));
                }
            } else {
                CommonFunctions.toDisplayToast(getResources().getString(R.string.lbl_no_check_internet), getContext());
            }
        } catch (Exception | Error e) {
            e.printStackTrace(); Crashlytics.logException(e);

        }
    }

    public void replacePage(Fragment fragment) {
        fragment.setArguments(bundle);
        getActivity().getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.flUsersTab2Container, fragment)
//                .addToBackStack(fragment.getClass().getName())
                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
                .commit();
    }

    public interface OnFragmentInteractionListener {
        void onFragmentInteraction(Uri uri);

        void toSetTitle(String s, boolean b);
    }

}
<file_sep>package com.hm.application.utils.insta.utils;

import android.util.Log;

import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.Arrays;

public class FileSearch {

    public static ArrayList<String> getDirectoryPaths(String directory) {
        ArrayList<String> pathArray = new ArrayList<>();
        File file = new File(directory);
        File[] listfiles = file.listFiles();
        for (int i = 0; i < listfiles.length; i++) {
            Log.d("hmapp", " isdirectory " + listfiles[i] + " : " + (listfiles[i].isDirectory()&& file.listFiles(new ImageFileFilter()).length > 0)
                    + " : " + listfiles[i].isDirectory()
//                    + " : " + Arrays.toString(file.listFiles())
                    + " : " +  (file.listFiles(new ImageFileFilter()).length > 0)
            );
            if (listfiles[i].isDirectory()&& file.listFiles(new ImageFileFilter()).length > 0) {
                pathArray.add(listfiles[i].getAbsolutePath());
            }
        }
        return pathArray;
    }

    /**
     * Search a directory and return a list of all **files** contained inside
     *
     * @param directory
     * @return
     */
    public static ArrayList<String> getFilePaths(String directory) {
        Log.d("hmapp Gallery", " getfilepaths : " + directory);
        ArrayList<String> pathArray = new ArrayList<>();
        File file = new File(directory);
        Log.d("hmaPp Gallery", "listFiles : " + Arrays.toString(file.listFiles())) ;

        File[] listfiles = file.listFiles();
        for (int i = 0; i < listfiles.length; i++) {
            if (listfiles[i].isFile()) {
                Log.d("hmapp Gallery", " getabsolutepath "+ listfiles[i].getAbsolutePath());
                pathArray.add(listfiles[i].getAbsolutePath());
            }
        }
        return pathArray;
    }

    /**
     * Checks the file to see if it has a compatible extension.
     */
    private static boolean isImageFile(String filePath) {
        return filePath.endsWith(".jpg") || filePath.endsWith(".png");
    }

    /**
     * This can be used to filter files.
     */
    private static class ImageFileFilter implements FileFilter {

        @Override
        public boolean accept(File file) {
            Log.d("Hmapp Gallery", " ImageFileFilter : " + file.getAbsolutePath());
            if (file.isDirectory()) {
                return true;
            }
            else
                return isImageFile(file.getAbsolutePath());
        }
    }

}
<file_sep>package com.hm.application.network;

import android.content.Context;
import android.util.Log;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.RetryPolicy;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.Volley;
import com.crashlytics.android.Crashlytics;


public class VolleySingleton {
    private static VolleySingleton mInstance;
    private static Context mContext;
    private RequestQueue mRequestQueue;

    private VolleySingleton(Context context) {
        mContext = context;
        mRequestQueue = getRequestQueue();
    }

    public static synchronized VolleySingleton getInstance(Context context) {
        if (mInstance == null) {
            mInstance = new VolleySingleton(context);
        }
        return mInstance;
    }

    private RequestQueue getRequestQueue() {
        if (mRequestQueue == null) {
            mRequestQueue = Volley.newRequestQueue(mContext.getApplicationContext());
        }
        return mRequestQueue;
    }

    public <T> void addToRequestQueue(Request<T> req, String tag) {
        try {
            Log.d("HM_URL", " tag 1: " + tag + " : " + req.getUrl());
            Log.d("HM_URL", " tag 2: " + new String(req.getBody(), "UTF-8"));
            req.setRetryPolicy(new RetryPolicy() {
                @Override
                public int getCurrentTimeout() {
                    return 50000;
                }

                @Override
                public int getCurrentRetryCount() {
                    return 50000;
                }

                @Override
                public void retry(VolleyError error) {
                    error.printStackTrace();
                }
            });
            getRequestQueue().add(req).setTag(tag);
        } catch (Exception | Error e) {
            e.printStackTrace(); Crashlytics.logException(e);

        }
    }


    public void cancelPendingRequests(Object tag) {
        if (this.mRequestQueue != null) {
            this.mRequestQueue.cancelAll(tag);
        }
    }

    public <T> void addToRequestQueue(Request<T> request) {
        getRequestQueue().add(request);
    }
}<file_sep>package com.hm.application.activity;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.crashlytics.android.Crashlytics;
import com.hm.application.R;
import com.hm.application.adapter.SlidingImageAdapter;
import com.hm.application.classes.Post;
import com.hm.application.common.MyPost;
import com.hm.application.fragments.CommentFragment;
import com.hm.application.fragments.TimelineLikeListFragment;
import com.hm.application.model.AppConstants;
import com.hm.application.model.User;
import com.hm.application.network.VolleySingleton;
import com.hm.application.utils.CommonFunctions;
import com.hm.application.utils.HmFonts;
import com.squareup.picasso.Picasso;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

import de.hdodenhof.circleimageview.CircleImageView;

public class SinglePostDataActivity extends AppCompatActivity {

    private RelativeLayout mrr_header_file, mRrVpMain;
    private CircleImageView mcircle_img;
    private TextView mtxt_label, mtxt_time_ago, mtxtSpdPost, mTvTimeLineId;
    private LinearLayout mLlSpdMain, mLlMainVpPost;
    private TextView mtxtNo_like, mtxtNo_comment, mTvUserLikeName;
    private FrameLayout mFlSpdHome;
    private NestedScrollView mNsvSpdPost;
    private CheckBox mChkPostLiked, mChkLike;

    private LinearLayout mll_footer;
    private ImageView mImgComment, mImgShare;
    private ViewPager mVp;
    private TabLayout mTl;

    // Comments
    private RecyclerView mRvCmt;
    private Button mBtnCmt;
    private LinearLayout mLlAddCmt, mllAddReply;
    private ImageView mIvProfilePic;
    private EditText mEdtCmt;
    private TextView mTvCuReply;


    private String timelineId = null, commentId = null;
    private JSONObject obj;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_single_post_data);
        try {
            toSetTitle();
            bindViews();
            toSetData();
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);

        }
    }

    private void toSetTitle() throws Error {
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setDisplayShowTitleEnabled(true);
            getSupportActionBar().setHomeAsUpIndicator(ContextCompat.getDrawable(this, R.drawable.ic_back_black_24dp));
            getSupportActionBar().setTitle(getResources().getString(R.string.app_name));
            getSupportActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.white)));
        }
    }

    private void bindViews() throws Error {
        mNsvSpdPost = findViewById(R.id.nsvSpdPost);
        mFlSpdHome = findViewById(R.id.flSpdHome);

        mLlSpdMain = findViewById(R.id.llSpdMain);
        mLlMainVpPost = findViewById(R.id.llMainVpPost);

        mrr_header_file = findViewById(R.id.rrHeaderMain);

        mRrVpMain = findViewById(R.id.rrVpMain);

        mcircle_img = findViewById(R.id.circle_img);
        mtxt_label = findViewById(R.id.txt_label);
        mtxt_label.setTypeface(HmFonts.getRobotoMedium(SinglePostDataActivity.this));

        mtxt_time_ago = findViewById(R.id.txt_time_ago);
        mtxt_time_ago.setTypeface(HmFonts.getRobotoRegular(SinglePostDataActivity.this));

        mtxtSpdPost = findViewById(R.id.txtSpdPost);
        mtxtSpdPost.setTypeface(HmFonts.getRobotoMedium(SinglePostDataActivity.this));

        mTvTimeLineId = findViewById(R.id.tvTimelineId);

        mChkPostLiked = findViewById(R.id.chkPostLiked);
        mChkLike = findViewById(R.id.chkLike);

        mtxtNo_like = findViewById(R.id.txtNo_like);
        mtxtNo_like.setTypeface(HmFonts.getRobotoRegular(SinglePostDataActivity.this));

        mtxtNo_comment = findViewById(R.id.txtNo_comment);
        mtxtNo_comment.setTypeface(HmFonts.getRobotoRegular(SinglePostDataActivity.this));

//        mTvUserLikeName = findViewById(R.id.tvUserLikeName);

        mll_footer = findViewById(R.id.llSdpFooter);

        mImgComment = findViewById(R.id.imgComment);
        mImgShare = findViewById(R.id.imgShare);

        mVp = findViewById(R.id.vpMainPost);
        mTl = findViewById(R.id.tlMainPost);


        mLlAddCmt = findViewById(R.id.llAddCmtSPD);
        mRvCmt = findViewById(R.id.rvCommentsSPD);
        mRvCmt.setNestedScrollingEnabled(false);
        mEdtCmt = findViewById(R.id.edtCfPost);
        mBtnCmt = findViewById(R.id.btnCfSend);
        mEdtCmt.setOnEditorActionListener(new EditText.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    toSetDataSending();
                }
                return false;
            }
        });

        mBtnCmt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d("hmapp", " comment submit spd: " + mEdtCmt.getText());
                toSetDataSending();
            }
        });

        mIvProfilePic = findViewById(R.id.imgCf);
        if (User.getUser(this).getPicPath() != null) {
            Picasso.with(this)
                    .load(AppConstants.URL + User.getUser(this).getPicPath().replaceAll("\\s", "%20"))
                    .resize(200, 200)
                    .error(R.color.light2)
                    .placeholder(R.color.light)
                    .into(mIvProfilePic);
        }
    }

    private void toSetDataSending() {
        try {
            if (commentId != null) {
                toSubmitReply();
            } else {
                toSubmitComment();
            }
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);

        }
    }

    private void toSubmitReply() {
        try {
            if (mEdtCmt.getText().toString().trim().length() > 0) {
                MyPost.toReplyOnComment(this, commentId, mEdtCmt.getText().toString().trim(), mTvCuReply);
                if (mllAddReply != null) {
                    toAddReply(mEdtCmt.getText().toString().trim(), mllAddReply);
                }
                mEdtCmt.setText("");
            } else {
                CommonFunctions.toDisplayToast("Empty", this);
            }
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);

        }
    }

    private void toSubmitComment() {
        try {
            if (mEdtCmt.getText().toString().trim().length() > 0) {
                MyPost.toCommentOnPost(this, timelineId, mEdtCmt.getText().toString().trim(), mLlAddCmt);
                toAddComment(mEdtCmt.getText().toString().trim(), mLlAddCmt);
                mEdtCmt.setText("");
            } else {
                CommonFunctions.toDisplayToast("Empty", this);
            }
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);

        }
    }

    private void toAddComment(String data, LinearLayout mLlAddCmt) {
        try {
            View itemView = LayoutInflater.from(this).inflate(R.layout.comment_user, null);
            if (itemView != null) {
                Context context = this;
                CircleImageView mIvCu;
                TextView mTvCuName, mTvCuCmt, mTvCuTime, mTvCuLike, mTvCuReply;

                mIvCu = itemView.findViewById(R.id.imgCu);
                Picasso.with(context).load(AppConstants.URL + User.getUser(context).getPicPath().replaceAll("\\s", "%20"))
                        .error(R.color.light2)
                        .placeholder(R.color.light)
                        .into(mIvCu);

                mTvCuName = itemView.findViewById(R.id.txtCuName);
                mTvCuName.setTypeface(HmFonts.getRobotoRegular(context));
                mTvCuName.setText(User.getUser(context).getUsername());

                mTvCuCmt = itemView.findViewById(R.id.txtCuCmt);
                mTvCuCmt.setTypeface(HmFonts.getRobotoRegular(context));
                mTvCuCmt.setText(data);

                mTvCuTime = itemView.findViewById(R.id.txtCuTime);
                mTvCuTime.setTypeface(HmFonts.getRobotoRegular(context));

                mTvCuLike = itemView.findViewById(R.id.txtCuLike);
                mTvCuLike.setTypeface(HmFonts.getRobotoRegular(context));
                mTvCuLike.setText("0 " + context.getString(R.string.str_like));

                mTvCuReply = itemView.findViewById(R.id.txtCuReply);
                mTvCuReply.setTypeface(HmFonts.getRobotoRegular(context));

                mLlAddCmt.addView(itemView);
//                new toDisplayComments().execute();
//                toDisplayComments();
                Post.toDisplayComments(timelineId, mRvCmt, this, mLlAddCmt);
                mLlAddCmt.requestFocus();
            }
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);

        }
    }

    private void toAddReply(String data, LinearLayout mLlAddCmt) {
        try {
            View itemView = LayoutInflater.from(this).inflate(R.layout.comment_user, null);
            if (itemView != null) {
                Context context = this;
                CircleImageView mIvCu;
                TextView mTvCuName, mTvCuCmt, mTvCuTime, mTvCuLike, mTvCuReply;

                mIvCu = itemView.findViewById(R.id.imgCu);
                Picasso.with(context).load(AppConstants.URL + User.getUser(context).getPicPath().replaceAll("\\s", "%20"))
                        .error(R.color.light2)
                        .placeholder(R.color.light)
                        .into(mIvCu);

                mTvCuName = itemView.findViewById(R.id.txtCuName);
                mTvCuName.setTypeface(HmFonts.getRobotoRegular(context));
                mTvCuName.setText(User.getUser(context).getUsername());

                mTvCuCmt = itemView.findViewById(R.id.txtCuCmt);
                mTvCuCmt.setTypeface(HmFonts.getRobotoRegular(context));
                mTvCuCmt.setText(data);

                mTvCuTime = itemView.findViewById(R.id.txtCuTime);
                mTvCuTime.setTypeface(HmFonts.getRobotoRegular(context));

                mTvCuLike = itemView.findViewById(R.id.txtCuLike);
                mTvCuLike.setTypeface(HmFonts.getRobotoRegular(context));
                mTvCuLike.setText("0 " + context.getString(R.string.str_like));

                mTvCuReply = itemView.findViewById(R.id.txtCuReply);
                mTvCuReply.setTypeface(HmFonts.getRobotoRegular(context));

                mLlAddCmt.addView(itemView);
//                new toDisplayComments().execute();
//                toDisplayComments();
                mLlAddCmt.requestFocus();
                Post.toDisplayComments(timelineId, mRvCmt, this, mLlAddCmt);
                mLlAddCmt.requestFocus();
            }
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);

        }
    }

    private void toSetData() {
        try {
            if (getIntent() != null) {
                Log.d("HmApp", " singlePostData : " + getIntent());
                if (getIntent().getStringExtra(AppConstants.BUNDLE) != null) {
                    obj = new JSONObject(getIntent().getStringExtra(AppConstants.BUNDLE));
                    if (getIntent().getStringExtra(AppConstants.TIMELINE_ID) != null) {
                        timelineId = getIntent().getStringExtra(AppConstants.TIMELINE_ID);
                    } else {
                        timelineId = obj.getString("timeline_id");
                    }
                    Log.d("HmApp", " SinglePost Timeline 1 " + timelineId);
                    toDisplayData(obj);
                } else if (getIntent().getStringExtra(AppConstants.TIMELINE_ID) != null) {
                    timelineId = getIntent().getStringExtra(AppConstants.TIMELINE_ID);
                    Log.d("HmApp", " SinglePost Timeline 2 " + timelineId);
                    if (CommonFunctions.isOnline(SinglePostDataActivity.this)) {
                        toDisplayNotificationData();
                    } else {
                        CommonFunctions.toDisplayToast(getResources().getString(R.string.lbl_no_check_internet), SinglePostDataActivity.this);
                    }
                }
            }
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);

        }
    }

    private void toCallCommentUi() {
        try {
            Bundle bundle = new Bundle();
            Log.d("hmapp", " Spd Timeline1" + timelineId);
            bundle.putString(AppConstants.TIMELINE_ID, obj.getString(getString(R.string.str_timeline_id_)));
            Log.d("hmapp", " Spd Timeline2 " + timelineId);
            CommentFragment cm = new CommentFragment();
            cm.setArguments(bundle);
            replaceMainHomePage(cm);
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);

        }
    }

    public void replaceMainHomePage(Fragment fragment) {
        Log.d("Hmapp", " agr replaceTabData 1 bundle  " + fragment.getArguments());
        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.flSpdHome, fragment)
//                .addToBackStack(fragment.getClass().getName())
                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
                .commit();
    }


    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                onBackPressed();
                break;
            default:
                break;
        }
        return super.onOptionsItemSelected(item);
    }

    public void toDisplayData(final JSONObject obj) throws Exception, Error {
        Log.d("hmapp", " data " + obj);
        if (!obj.isNull(getString(R.string.str_username_))) {
            mtxt_label.setText(CommonFunctions.firstLetterCaps(obj.getString(getString(R.string.str_username_))));
        } else {
            mtxt_label.setText(CommonFunctions.firstLetterCaps(User.getUser(SinglePostDataActivity.this).getUsername()));
        }
        if (!obj.isNull(getString(R.string.str_post_small)) && obj.getString(getString(R.string.str_post_small)).trim().length() > 0) {
            mtxtSpdPost.setVisibility(View.VISIBLE);
            mtxtSpdPost.setText(User.getUser(SinglePostDataActivity.this).getUsername()+" : "+obj.getString(getString(R.string.str_post_small)));
        } else if (!obj.isNull(getString(R.string.str_caption)) && obj.getString(getString(R.string.str_caption)).trim().length() > 0) {
            mtxtSpdPost.setVisibility(View.VISIBLE);
            mtxtSpdPost.setText(User.getUser(SinglePostDataActivity.this).getUsername()+" : "+obj.getString(getString(R.string.str_caption)));
        } else if (!obj.isNull(getString(R.string.str_post_data)) && obj.getString(getString(R.string.str_post_data)).trim().length() > 0) {
            mtxtSpdPost.setVisibility(View.VISIBLE);
            mtxtSpdPost.setText(User.getUser(SinglePostDataActivity.this).getUsername()+" : "+obj.getString(getString(R.string.str_post_data)));
        } else {
            mtxtSpdPost.setVisibility(View.GONE);
        }

        if (!obj.isNull(getString(R.string.str_time))) {
            mtxt_time_ago.setText(CommonFunctions.toSetDate(obj.getString(getString(R.string.str_time))));
        }
        if (!obj.isNull(getString(R.string.str_timeline_id_))) {
            mTvTimeLineId.setText(obj.getString(getString(R.string.str_timeline_id_)));
        }
//        if (!obj.isNull(getString(R.string.str_friend_like))) {
//            mTvUserLikeName.setText(obj.getString(getString(R.string.str_friend_like)));
//        }
        if (!obj.isNull(getString(R.string.str_like_count)) && !obj.getString(getString(R.string.str_like_count)).equals("0")) {
            if (!obj.isNull(getString(R.string.str_friend_like))) {
                mtxtNo_like.setVisibility(View.VISIBLE);
                mtxtNo_like.setText("Liked by "+(obj.getString(getString(R.string.str_friend_like)) + " and " + obj.getString(getString(R.string.str_like_count)) + " others"));
            }else if (!obj.isNull(getString(R.string.str_like_count))){
                mtxtNo_like.setVisibility(View.VISIBLE);
                mtxtNo_like.setText(obj.getString(getString(R.string.str_like_count)) + " likes");
            }
        }else {
            mtxtNo_like.setVisibility(View.GONE);
        }

        if (!obj.isNull(getString(R.string.str_comment_count))) {
            mtxtNo_comment.setText(obj.getString(getString(R.string.str_comment_count)) + " " + getString(R.string.str_comment));
        }
//        if (!obj.isNull(getString(R.string.str_share_count))) {
//            mtxtNo_share.setText(obj.getString(getString(R.string.str_share_count)) + " " + getResources().getString(R.string.str_share));
//        }
        if (User.getUser(SinglePostDataActivity.this).getPicPath() != null) {
            Picasso.with(SinglePostDataActivity.this)
                    .load(AppConstants.URL + User.getUser(SinglePostDataActivity.this).getPicPath().replaceAll("\\s", "%20"))
                    .error(R.color.light2)
                    .placeholder(R.color.light)
                    .resize(100, 100)
                    .into(mcircle_img);
        }

        if (!obj.isNull(getString(R.string.str_image_url))) {
            mVp.setAdapter(
                    new SlidingImageAdapter(
                            SinglePostDataActivity.this,
                            obj.getString(getString(R.string.str_image_url)).split(","),
                            null,
                            null,
                            mTl)
            );
            if (obj.getString(getString(R.string.str_image_url)).split(",").length > 1) {
                mTl.setupWithViewPager(mVp);
            } else {
                mTl.setVisibility(View.GONE);
            }
        } else if (!obj.isNull(getString(R.string.str_image))) {
            mVp.setAdapter(
                    new SlidingImageAdapter(
                            SinglePostDataActivity.this,
                            obj.getString(getString(R.string.str_image)).split(","),
                            null,
                            null,
                            mTl)
            );
            mTl.setupWithViewPager(mVp);
        } else {
            mVp.setVisibility(View.GONE);
            mTl.setVisibility(View.GONE);
        }

        mrr_header_file.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    startActivity(
                            new Intent(SinglePostDataActivity.this, UserInfoActivity.class)
                                    .putExtra(AppConstants.F_UID, obj.getString("Uid")));
                } catch (Exception | Error e) {
                    e.printStackTrace();
                    Crashlytics.logException(e);

                }
            }
        });

        mImgShare.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    CommonFunctions
                            .toShareData(SinglePostDataActivity.this,
                                    getString(R.string.app_name),
                                    obj.getString(getString(R.string.str_caption)),
                                    obj.getString(getString(R.string.str_timeline_id_)), null);
                } catch (Exception | Error e) {
                    e.printStackTrace();
                    Crashlytics.logException(e);

                }
            }
        });

        mChkLike.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    MyPost.toLikeUnlikePost(SinglePostDataActivity.this, obj.getString(getString(R.string.str_timeline_id_)), null, null, mChkPostLiked, mChkLike);
                } catch (Exception | Error e) {
                    e.printStackTrace();
                    Crashlytics.logException(e);

                }
            }
        });

        mtxtNo_like.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    Bundle bundle = new Bundle();
                    bundle.putString(AppConstants.TIMELINE_ID, obj.getString(getString(R.string.str_timeline_id_)));
                    TimelineLikeListFragment time = new TimelineLikeListFragment();
                    time.setArguments(bundle);
                    replaceMainHomePage(time);
                } catch (Exception | Error e) {
                    e.printStackTrace();
                    Crashlytics.logException(e);

                }
            }
        });

        mImgComment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                toCallCommentUi();
            }
        });

        mtxtNo_comment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                toCallCommentUi();
            }
        });
        // toDisplay comments Below
//        Bundle bundle = new Bundle();
//        bundle.putString(AppConstants.TIMELINE_ID, timelineId);
//        CommentFragment cm = new CommentFragment();
//        cm.setArguments(bundle);
//        getSupportFragmentManager()
//                .beginTransaction()
//                .replace(R.id.flSpdComment, cm)
//                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
//                .commit();
        Post.toDisplayComments(timelineId, mRvCmt, this, mLlAddCmt);
    }

    public void toDisplayNotificationData() {
        try {
            VolleySingleton.getInstance(SinglePostDataActivity.this)
                    .addToRequestQueue(
                            new StringRequest(Request.Method.POST,
                                    AppConstants.URL + getString(R.string.str_notification_uid) + getString(R.string.str_php),
                                    new Response.Listener<String>() {

                                        @Override
                                        public void onResponse(String res) {
                                            try {
                                                Log.d("HmApp", "notification:" + res);
                                                if (res != null && res.trim().length()>0){
                                                    JSONArray array = new JSONArray(res.trim());
                                                    if (array != null) {
                                                        if (array.length() > 0) {
                                                            if (!array.isNull(0)) {
                                                                obj = array.getJSONObject(0);
                                                                toDisplayData(obj);
                                                            }
                                                        }

                                                    }
                                                }
                                            } catch (Exception | Error e) {
                                                e.printStackTrace();
                                                Crashlytics.logException(e);

                                            }
                                        }
                                    },
                                    new Response.ErrorListener() {
                                        @Override
                                        public void onErrorResponse(VolleyError error) {
                                            error.printStackTrace();
                                        }
                                    }
                            ) {
                                @Override
                                protected Map<String, String> getParams() {
                                    Map<String, String> params = new HashMap<>();
                                    params.put(getString(R.string.str_action_), getString(R.string.str_notification_post));
                                    params.put(getString(R.string.str_timeline_id_), timelineId);
                                    Log.d("HmApp", "Notification timeline: " + timelineId);
                                    return params;
                                }
                            }
                            , getString(R.string.str_notification_post));
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);

        }
    }
}<file_sep>package com.hm.application.fragments;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ProgressBar;

import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.crashlytics.android.Crashlytics;
import com.hm.application.R;
import com.hm.application.activity.SinglePostDataActivity;
import com.hm.application.classes.UserTimelinePostNew;
import com.hm.application.model.AppConstants;
import com.hm.application.model.User;
import com.hm.application.network.VolleySingleton;
import com.hm.application.utils.CommonFunctions;

import org.json.JSONArray;

import java.util.HashMap;
import java.util.Map;

public class UserTab1Fragment extends Fragment {

    private LinearLayout mLlPostMain;
    private JSONArray array;
    private String uid;
    private ProgressBar mPb;

    private OnFragmentInteractionListener mListener;

    public UserTab1Fragment() {
        // Required empty public constructor
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        if (context instanceof OnFragmentInteractionListener) {
            mListener = (OnFragmentInteractionListener) context;
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
        mListener = null;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_user_tab1, container, false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        try {
            mLlPostMain = getActivity().findViewById(R.id.llPostMain);
            mPb = getActivity().findViewById(R.id.progressBarPM);
            if (mLlPostMain.getChildCount() > 0) {
                mLlPostMain.removeAllViews();
            }
            checkInternetConnection();
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);
        }
    }

    private void checkInternetConnection() {
        try {
            uid = User.getUser(getContext()).getUid();
            if (CommonFunctions.isOnline(getContext())) {
                if (getArguments() != null) {
                    if (getArguments().getBoolean("other_user")) {
                        if (getArguments().getString("fetch_timeline") != null) {
                            toDisplayData(getArguments().getString("fetch_timeline"), getArguments().getString("name"));
                        } else if (getArguments().getString(AppConstants.F_UID) != null) {
                            uid = getArguments().getString(AppConstants.F_UID);
                            new toGetData().execute();
                        } else {
                            new toGetData().execute();
                        }
                    } else {
                        new toGetData().execute();
                    }
                } else {
                    new toGetData().execute();
                }
            } else {
                CommonFunctions.toDisplayToast(getResources().getString(R.string.lbl_no_check_internet), getContext());
            }
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);
        }
    }

    private void toDisplayData(String res, String name) {
        try {
            if (res != null && res.length() > 0) {
                array = new JSONArray(res);
                if (array != null) {
                    if (array.length() > 0) {
                        for (int i = 0; i < array.length(); i++) {
                            if (!array.getJSONObject(i).isNull(getString(R.string.str_activity_small))) {
                                if (array.getJSONObject(i).getString(getString(R.string.str_activity_small)).equals(getString(R.string.str_photo_small))) {
//                                UserTimeLinePost.toDisplayNormalPost(array.getJSONObject(i), getContext(), mLlPostMain, i, name, UserTab1Fragment.this);
                                    UserTimelinePostNew.toDisplayPost(array.getJSONObject(i), getContext(), mLlPostMain, i, name, UserTab1Fragment.this);
//                            } else if (array.getJSONObject(i).getString(getString(R.string.str_activity_small)).equals(getString(R.string.str_post_small))) {
//                                UserTimeLinePost.toDisplayNormalPost(array.getJSONObject(i), getContext(), mLlPostMain, i, name, UserTab1Fragment.this);
                                } else if (array.getJSONObject(i).getString(getString(R.string.str_activity_small)).equals(getString(R.string.str_album_small))) {
//                                UserTimeLinePost.toDisplayPhotoPost(array.getJSONObject(i), getContext(), mLlPostMain, i, name, UserTab1Fragment.this);
                                    UserTimelinePostNew.toDisplayPost(array.getJSONObject(i), getContext(), mLlPostMain, i, name, UserTab1Fragment.this);
//                            } else {
//                                UserTimeLinePost.toDisplayNormalPost(array.getJSONObject(i), getContext(), mLlPostMain, i, name, UserTab1Fragment.this);
                                }
                            }
                        }
                    } else {
                        CommonFunctions.toDisplayToast(getString(R.string.str_no_post_found), getContext());
                    }
                } else {
                    CommonFunctions.toDisplayToast(getString(R.string.str_no_post_found), getContext());
                }
            } else {
                CommonFunctions.toDisplayToast(getString(R.string.str_no_post_found), getContext());
            }
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);
        }
    }

    public void toCallSinglePostData(int position, String from) {
        try {
            startActivity(new Intent(getContext(), SinglePostDataActivity.class)
                    .putExtra(AppConstants.FROM, from)
                    .putExtra(AppConstants.BUNDLE, array.getJSONObject(position).toString()));
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);
        }
    }

    public interface OnFragmentInteractionListener {
        void onFragmentInteraction(Uri uri);

        void toSetTitle(String s, boolean b);
    }

    private class toGetData extends AsyncTask<Void, Void, Void> {
        @Override
        protected Void doInBackground(Void... voids) {
            try {
                if (mLlPostMain.getChildCount() > 0) {
                    mLlPostMain.removeAllViews();
                }
                VolleySingleton.getInstance(getContext())
                        .addToRequestQueue(
                                new StringRequest(Request.Method.POST,
                                        AppConstants.URL + getString(R.string.str_feed) + getString(R.string.str_php),
                                        new Response.Listener<String>() {

                                            @Override
                                            public void onResponse(String response) {
                                                Log.d("hmapp", " response : fetch_timeline " + response);
                                                toDisplayData(response, User.getUser(getContext()).getUsername());
                                            }
                                        },
                                        new Response.ErrorListener() {
                                            @Override
                                            public void onErrorResponse(VolleyError error) {
                                                error.printStackTrace();
                                            }
                                        }
                                ) {
                                    @Override
                                    protected Map<String, String> getParams() {
                                        Map<String, String> params = new HashMap<String, String>();
                                        params.put(getString(R.string.str_action_), getString(R.string.str_fetch_timeline_));
                                        params.put(getString(R.string.str_uid), uid);
                                        return params;
                                    }
                                }
                                , getString(R.string.str_fetch_timeline_));
            } catch (Exception | Error e) {
                e.printStackTrace();
                Crashlytics.logException(e);
            }
            return null;
        }
    }
}<file_sep>package com.hm.application.services;

public interface SmsListener {
    void messageReceived(String str);
}
<file_sep>package com.hm.application.adapter;

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.crashlytics.android.Crashlytics;
import com.hm.application.R;
import com.hm.application.activity.UserInfoActivity;
import com.hm.application.common.MyFriendRequest;
import com.hm.application.model.AppConstants;
import com.hm.application.utils.CommonFunctions;
import com.hm.application.utils.HmFonts;
import com.squareup.picasso.Picasso;

import org.json.JSONArray;

import de.hdodenhof.circleimageview.CircleImageView;

public class UserFollowingListAdapter extends RecyclerView.Adapter<com.hm.application.adapter.UserFollowingListAdapter.ViewHolder> {
    private Context context;
    private JSONArray array;

    public UserFollowingListAdapter(Context ctx, JSONArray data) {
        context = ctx;
        array = data;
    }

    @NonNull
    @Override
    public com.hm.application.adapter.UserFollowingListAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new com.hm.application.adapter.UserFollowingListAdapter.ViewHolder(LayoutInflater.from(context).inflate(R.layout.friend_request_item_layout, parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull com.hm.application.adapter.UserFollowingListAdapter.ViewHolder holder, int position) {
        try {
            if (!array.getJSONObject(position).isNull(context.getString(R.string.str_name))) {
                holder.mTvName.setText(array.getJSONObject(position).getString(context.getString(R.string.str_name)));
            }
            if (!array.getJSONObject(position).isNull(context.getString(R.string.str_mutual_friend_count))) {
                holder.mTvData.setText(array.getJSONObject(position).getString(context.getString(R.string.str_mutual_friend_count)) + " " + context.getString(R.string.str_common_friends));
            } else {
                holder.mTvData.setText("0 Common Friends");
            }
            if (!array.getJSONObject(position).isNull(context.getString(R.string.str_profile_pic))) {
                if (array.getJSONObject(position).getString(context.getString(R.string.str_profile_pic)).toLowerCase().contains("upload")) {
                    Picasso.with(context)
                            .load(AppConstants.URL + array.getJSONObject(position).getString(context.getString(R.string.str_profile_pic)).replaceAll("\\s", "%20"))
                            .placeholder(R.color.light)
                            .error(R.color.light)
                            .into(holder.mIvProfilePic);
                } else {
                    Picasso.with(context)
                            .load(array.getJSONObject(position).getString(context.getString(R.string.str_profile_pic)).replaceAll("\\s", "%20"))
                            .placeholder(R.color.light)
                            .error(R.color.light)
                            .into(holder.mIvProfilePic);
                }
            }
        } catch (Exception | Error e) {
            e.printStackTrace(); Crashlytics.logException(e);

        }
    }

    @Override
    public int getItemCount() {
        return array == null ? 0 : array.length();
    }

    private void toAskConfirmUnFollow(final String f_uid, String f_name, final Button mBtnIgnore) throws Error {
        try {
            AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.MyAlertDialogTheme);
            builder.setTitle(context.getString(R.string.str_unfollow) + "\n" + CommonFunctions.firstLetterCaps(f_name));
            builder.setMessage(context.getString(R.string.str_msg_unfollow_friend) + " " + f_name);
            builder.setCancelable(true);

            builder.setPositiveButton(
                    context.getString(R.string.str_lbl_yes),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            MyFriendRequest.toUnFriendRequest(context, f_uid, mBtnIgnore);
                            dialog.cancel();
                        }
                    });

            builder.setNegativeButton(
                    context.getString(R.string.str_lbl_no),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.cancel();
                        }
                    });

            AlertDialog alert1 = builder.create();
            alert1.show();

        } catch (Exception | Error e) {
            e.printStackTrace(); Crashlytics.logException(e);

        }
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        private CircleImageView mIvProfilePic;
        private Button mBtnIgnore, mBtnConfirm;
        private TextView mTvName, mTvData;
        private RelativeLayout mRl;

        ViewHolder(View itemView) {
            super(itemView);
            try {
                mRl = itemView.findViewById(R.id.rr_friend_req);
                mIvProfilePic = itemView.findViewById(R.id.imgFriendPic);

                mBtnConfirm = itemView.findViewById(R.id.btnFrConfirm);
                mBtnConfirm.setTypeface(HmFonts.getRobotoBold(context));
                mBtnConfirm.setVisibility(View.GONE);

                mBtnIgnore = itemView.findViewById(R.id.btnFrIgnore);
//                mBtnIgnore.setText(context.getString(R.string.str_unfollow));
                mBtnIgnore.setText(CommonFunctions.firstLetterCaps(context.getString(R.string.str_following_small)));
                mBtnIgnore.setTextColor(ContextCompat.getColor(context, R.color.grey5));
                mBtnIgnore.setBackground(ContextCompat.getDrawable(context, R.drawable.round_border_white));
                mBtnIgnore.setTypeface(HmFonts.getRobotoBold(context));

                mTvName = itemView.findViewById(R.id.txt_friend_name);
                mTvName.setTypeface(HmFonts.getRobotoBold(context));

                mTvData = itemView.findViewById(R.id.txt_friend_data);
                mTvData.setTypeface(HmFonts.getRobotoRegular(context));

                mTvName.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        try {
                            context.startActivity(new Intent(context, UserInfoActivity.class).putExtra(AppConstants.F_UID, array.getJSONObject(getAdapterPosition()).getString(context.getString(R.string.str_uid))));
                        } catch (Exception | Error e) {
                            e.printStackTrace(); Crashlytics.logException(e);

                        }
                    }
                });

                mRl.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        try {
                            context.startActivity(new Intent(context, UserInfoActivity.class).putExtra(AppConstants.F_UID, array.getJSONObject(getAdapterPosition()).getString(context.getString(R.string.str_uid))));
                        } catch (Exception | Error e) {
                            e.printStackTrace(); Crashlytics.logException(e);

                        }
                    }
                });

                mBtnIgnore.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        try {
                            mBtnIgnore.setEnabled(false);
//                            if (mBtnIgnore.getText().toString().trim().equals(context.getString(R.string.str_unfollow))) {
                            if (mBtnIgnore.getText().toString().trim().equals(CommonFunctions.firstLetterCaps(context.getString(R.string.str_following_small)))) {
                                toAskConfirmUnFollow(array.getJSONObject(getAdapterPosition()).getString(context.getString(R.string.str_uid)), array.getJSONObject(getAdapterPosition()).getString(context.getString(R.string.str_name)), mBtnIgnore);
                            } else if (mBtnIgnore.getText().toString().trim().equals(context.getString(R.string.str_follow))) {
                                MyFriendRequest.toFollowFriendRequest(context, array.getJSONObject(getAdapterPosition()).getString(context.getString(R.string.str_uid)), mBtnIgnore);
                            }
                        } catch (Exception | Error e) {
                            e.printStackTrace(); Crashlytics.logException(e);

                        }
                    }
                });
            } catch (Exception | Error e) {
                e.printStackTrace(); Crashlytics.logException(e);

            }
        }
    }
}<file_sep>package com.hm.application.services;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.SmsMessage;

import com.crashlytics.android.Crashlytics;

public class SmsReceiver extends BroadcastReceiver {
    private static SmsListener mListener;

    public static void bindListener(SmsListener listener) {
        mListener = listener;
    }

    public void onReceive(Context context, Intent intent) {
        try {
            Object[] pdus = (Object[]) intent.getExtras().get("pdus");
            if (pdus != null) {
                for (Object obj : pdus) {
                    SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) obj);
                    if (smsMessage.getDisplayOriginatingAddress().contains("SNSWAP")) {
                        String messageBody = smsMessage.getMessageBody();
                        if (messageBody != null) {
                            mListener.messageReceived(messageBody);
//                        } else {
//                            FirebaseCrash.log("SMSReceiver:1 " + smsMessage.getDisplayMessageBody() + "::" + smsMessage.getEmailBody() + "::" + smsMessage.getEmailFrom() + "::" + smsMessage.getPseudoSubject() + "::" + smsMessage.getMessageBody() + "::" + smsMessage.getStatus() + "::" + smsMessage.getServiceCenterAddress() + "::" + smsMessage.getOriginatingAddress() + "::" + smsMessage.getDisplayOriginatingAddress());
                        }
//                    } else {
//                        FirebaseCrash.log("SMSReceiver:2 " + smsMessage.getDisplayMessageBody() + "::" + smsMessage.getEmailBody() + "::" + smsMessage.getEmailFrom() + "::" + smsMessage.getPseudoSubject() + "::" + smsMessage.getMessageBody() + "::" + smsMessage.getStatus() + "::" + smsMessage.getServiceCenterAddress() + "::" + smsMessage.getOriginatingAddress() + "::" + smsMessage.getDisplayOriginatingAddress());
                    }
                }
//                return;
            }
//            FirebaseCrash.log("SMSReceiver:3 " + intent.getExtras());
//            return;
        } catch (Exception | Error e) {
            e.printStackTrace(); Crashlytics.logException(e);
        }
    }
}
<file_sep>package com.hm.application.fragments;

import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.crashlytics.android.Crashlytics;
import com.hm.application.R;
import com.hm.application.adapter.NotificationAdapter;
import com.hm.application.model.AppConstants;
import com.hm.application.model.User;
import com.hm.application.network.VolleySingleton;
import com.hm.application.utils.CommonFunctions;

import org.json.JSONArray;

import java.util.HashMap;
import java.util.Map;

public class NotificationFollowRequestFragment extends Fragment {

    private RecyclerView mRvNfMain;

    public NotificationFollowRequestFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_follow_request, container, false);
    }


    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        checkInternetConnection();
    }

    private void checkInternetConnection() {
        try {
            if (CommonFunctions.isOnline(getContext())) {
                new toGetFollowNotification().execute();
            } else {
                CommonFunctions.toDisplayToast(getResources().getString(R.string.lbl_no_check_internet), getContext());
            }
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);

        }
    }

    private class toGetFollowNotification extends AsyncTask<Void, Void, Void> {
        @Override
        protected Void doInBackground(Void... voids) {
            try {
                VolleySingleton.getInstance(getContext())
                        .addToRequestQueue(
                                new StringRequest(Request.Method.POST,
                                        AppConstants.URL + getString(R.string.str_notification_uid) + getContext().getResources().getString(R.string.str_php),
                                        new Response.Listener<String>() {

                                            @Override
                                            public void onResponse(String res) {
                                                Log.d("HmApp", "notification:" + res);
                                                try {
                                                    if (res != null && res.length() > 0) {
                                                        JSONArray array = new JSONArray(res.trim());
                                                        if (array != null) {
                                                            if (array.length() > 0) {
                                                                mRvNfMain = getActivity().findViewById(R.id.rvMNFR);
                                                                mRvNfMain.setLayoutManager(new LinearLayoutManager(getContext()));
                                                                mRvNfMain.hasFixedSize();
                                                                mRvNfMain.setAdapter(new NotificationAdapter(getContext(), array));

                                                            } else {
                                                                CommonFunctions.toDisplayToast("No Notification", getContext());
                                                            }
                                                        } else {
                                                            CommonFunctions.toDisplayToast("No Notification", getContext());
                                                        }
                                                    } else {
                                                        CommonFunctions.toDisplayToast("No Notification", getContext());
                                                    }
                                                } catch (Exception | Error e) {
                                                    e.printStackTrace();
                                                    Crashlytics.logException(e);
                                                }
                                            }
                                        },
                                        new Response.ErrorListener() {
                                            @Override
                                            public void onErrorResponse(VolleyError error) {
                                                error.printStackTrace();
                                            }
                                        }
                                ) {
                                    @Override
                                    protected Map<String, String> getParams() {
                                        Map<String, String> params = new HashMap<String, String>();
                                        params.put(getString(R.string.str_action_), getString(R.string.str_list_notification));
                                        params.put(getString(R.string.str_uid), User.getUser(getContext()).getUid());
                                        return params;
                                    }
                                }
                                , getContext().getString(R.string.str_sent_notification));
            } catch (Exception | Error e) {
                e.printStackTrace();
                Crashlytics.logException(e);
            }
            return null;
        }
    }
}<file_sep>package com.hm.application.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toolbar;

import com.crashlytics.android.Crashlytics;
import com.hm.application.R;
import com.hm.application.classes.Common_Alert_box;
import com.hm.application.fragments.ChangePasswordFragment;
import com.hm.application.fragments.UserProfileEditFragment;
import com.hm.application.fragments.UserTab21Fragment;
import com.hm.application.model.User;
import com.hm.application.utils.CommonFunctions;
import com.hm.application.utils.HmFonts;


public class AccountSettingsActivity extends AppCompatActivity {

    private RelativeLayout mRlAccSettingMain, mRlAccSettingTool, mRlAccSettingTb;
    private LinearLayout mLlLblAccount, mLlLblSupport, mLlAccountSetting;
    private Toolbar mProfileToolBar;
    private ImageView mIvBackArrow;
    private TextView mTvLblOption, mTvLblAccount, mTvPhotos, mTvPostLiked, mTvEditProf, mTvCngPassword, mTvBlockUser, mTvPrivateAcc, mTvLblSupport, mTvProblem, mTvHelpCenter, mTvAddAccount, mTvLogout;
    private Switch mSwitchAccount;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_accountsettings);
        try {
            bindViews();
        } catch (Exception | Error e) {
            e.printStackTrace();
            Crashlytics.logException(e);
        }    }

    private void bindViews() throws Error {
        mRlAccSettingMain = findViewById(R.id.rlAccSettingMain);
        mRlAccSettingTool = findViewById(R.id.rlAccSettingTool);
        mRlAccSettingTb = findViewById(R.id.rlAccSettingTb);

        mLlLblAccount = findViewById(R.id.llLblAccount);
        mLlLblSupport = findViewById(R.id.llLblSupport);
        mLlAccountSetting = findViewById(R.id.llAccountSetting);

        mIvBackArrow = findViewById(R.id.ivBackArrow);

        mTvLblOption = findViewById(R.id.tvLblOption);
        mTvLblOption.setTypeface(HmFonts.getRobotoBold(AccountSettingsActivity.this));

        mTvPhotos = findViewById(R.id.tvPhotos);
        mTvPhotos.setTypeface(HmFonts.getRobotoRegular(AccountSettingsActivity.this));

        mTvLblAccount = findViewById(R.id.tvLblAccount);
        mTvLblAccount.setTypeface(HmFonts.getRobotoBold(AccountSettingsActivity.this));

        mTvPostLiked = findViewById(R.id.tvPostLiked);
        mTvPostLiked.setTypeface(HmFonts.getRobotoRegular(AccountSettingsActivity.this));

        mTvEditProf = findViewById(R.id.tvEditProf);
        mTvEditProf.setTypeface(HmFonts.getRobotoRegular(AccountSettingsActivity.this));

        mTvCngPassword = findViewById(R.id.tvCngPassword);
        mTvCngPassword.setTypeface(HmFonts.getRobotoRegular(AccountSettingsActivity.this));

        mTvBlockUser = findViewById(R.id.tvBlockUser);
        mTvBlockUser.setTypeface(HmFonts.getRobotoRegular(AccountSettingsActivity.this));

        mTvLblSupport = findViewById(R.id.tvLblSupport);
        mTvLblSupport.setTypeface(HmFonts.getRobotoBold(AccountSettingsActivity.this));

        mTvProblem = findViewById(R.id.tvProblem);
        mTvProblem.setTypeface(HmFonts.getRobotoRegular(AccountSettingsActivity.this));

        mTvHelpCenter = findViewById(R.id.tvHelpCenter);
        mTvHelpCenter.setTypeface(HmFonts.getRobotoRegular(AccountSettingsActivity.this));

        mTvAddAccount = findViewById(R.id.tvAddAccount);
        mTvAddAccount.setTypeface(HmFonts.getRobotoRegular(AccountSettingsActivity.this));
        mTvAddAccount.setVisibility(View.GONE);

        mTvLogout = findViewById(R.id.tvLogout);
        mTvLogout.setTypeface(HmFonts.getRobotoRegular(AccountSettingsActivity.this));

        mSwitchAccount = findViewById(R.id.switchAccount);
        mSwitchAccount.setTypeface(HmFonts.getRobotoBold(AccountSettingsActivity.this));

        if (User.getUser(AccountSettingsActivity.this).getStatus() == 1) {
            mSwitchAccount.setChecked(true);
        } else {
            mSwitchAccount.setChecked(false);
        }

        mSwitchAccount.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    Common_Alert_box.toPrivateAccount(AccountSettingsActivity.this, true);
                } else {
                    Common_Alert_box.toPrivateAccount(AccountSettingsActivity.this, false);
                }
            }
        });

        mTvHelpCenter.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Common_Alert_box.toContactUs(AccountSettingsActivity.this);
            }
        });

        mTvLogout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CommonFunctions.toLogout(AccountSettingsActivity.this);
            }
        });

        mTvEditProf.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                replaceMainHomePage(new UserProfileEditFragment());
            }
        });

        mTvPhotos.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                replaceMainHomePage(new UserTab21Fragment());
            }
        });

        mIvBackArrow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });

        mTvCngPassword.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                replaceMainHomePage(new ChangePasswordFragment());
            }
        });
    }

    public void replaceMainHomePage(Fragment fragment) {
        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.rlAccSettingMain, fragment)
//                .addToBackStack(fragment.getClass().getName())
                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
                .commit();
    }
}
















<file_sep>package com.hm.application.fragments;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.hm.application.R;

public class Main_HomeFragment extends Fragment {


    public Main_HomeFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_main_home, container, false);
    }


    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }

    public void replacePage(Fragment fragment) {
        getActivity().getSupportFragmentManager()
                .beginTransaction()
//                .addToBackStack(fragment.getClass().getName())
                .replace(R.id.flHomeContainer, fragment)
                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
                .commit();
    }
}<file_sep>org.gradle.jvmargs=-Xmx3000m

android.enableBuildCache=false<file_sep>package com.hm.application.model;

import android.content.Context;
import android.content.SharedPreferences.Editor;
import android.util.Log;

import com.crashlytics.android.Crashlytics;
import com.google.gson.Gson;
import com.hm.application.R;

import org.json.JSONObject;

//

public class AppDataStorage {

    private static final String USER_INFO = "USER_INFO";
    private static final String USER_INFO_PREFERS = "USER_INFO_PREFERS";

    public static void getUserInfo(Context context) {
        try {
            String us = context.getSharedPreferences(USER_INFO_PREFERS, 0).getString(USER_INFO, null);
            if (us != null) {
                User user = User.getUser(context);
                JSONObject userJSON = new JSONObject(us);
                // {"dob":"1\/1\/1990","email":"swapnil","gender":"M","livesIn":"NSP","mobile":"123454","name":"<NAME>","notificationCount":0,"picPath":"uploads\/20\/profile_pics\/23-03-2018 16:28:24 PM_202879ad42dec8375e.jpg","referralCode":"123","uid":"20","username":"swapnil"}
                Log.d("HmApp", " getUserInfo " + userJSON);
                if (!userJSON.isNull(context.getString(R.string.str_uid))) {
                    user.setUid(userJSON.getString(context.getString(R.string.str_uid)));
                }
                if (!userJSON.isNull("email")) {
                    user.setEmail(userJSON.getString("email"));
                }
                if (!userJSON.isNull("name")) {
                    user.setName(userJSON.getString("name"));
                }

                if (!userJSON.isNull("username")) {
                    user.setUsername(userJSON.getString("username"));
                }
                if (!userJSON.isNull("mobile")) {
                    user.setMobile(userJSON.getString("mobile"));
                }
                if (!userJSON.isNull("dob")) {
                    user.setDob(userJSON.getString("dob"));
                }
                if (!userJSON.isNull("picPath")) {
                    user.setPicPath(userJSON.getString("picPath"));
                }
                if (!userJSON.isNull("livesIn")) {
                    user.setLivesIn(userJSON.getString("livesIn"));
                }
                if (!userJSON.isNull("referralCode")) {
                    user.setReferralCode(userJSON.getString("referralCode"));
                }
                if (!userJSON.isNull("gender")) {
                    user.setGender(userJSON.getString("gender"));
                }
                if (!userJSON.isNull("fromDest")) {
                    user.setFromDest(userJSON.getString("fromDest"));
                }
                if (!userJSON.isNull("relationStatus")) {
                    user.setRelationStatus(userJSON.getString("relationStatus"));
                }
                if (!userJSON.isNull("favQuote")) {
                    user.setFavQuote(userJSON.getString("favQuote"));
                }
                if (!userJSON.isNull("bio")) {
                    user.setBio(userJSON.getString("bio"));
                }
                if (!userJSON.isNull("fcmToken")) {
                    user.setFcmToken(userJSON.getString("fcmToken"));
                }
                if (!userJSON.isNull("notificationCount")) {
                    user.setNotificationCount(userJSON.getInt("notificationCount"));
                }
            }
        } catch (Exception | Error e) {
            e.printStackTrace(); Crashlytics.logException(e);

        }
    }

    public static void setUserInfo(Context context) {
        try {
            Editor editor = context.getSharedPreferences(USER_INFO_PREFERS, 0).edit();
            Log.d("HmApp", " setUserInfo " + new JSONObject(new Gson().toJson(User.getUser(context))).toString());
            editor.putString(USER_INFO, new JSONObject(new Gson().toJson(User.getUser(context))).toString());
            editor.apply();
            editor.commit();
        } catch (Exception | Error e) {
            e.printStackTrace(); Crashlytics.logException(e);

        }
    }
}<file_sep>package com.hm.application.network;

import com.android.volley.NetworkResponse;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import com.crashlytics.android.Crashlytics;

import org.apache.http.HttpEntity;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.util.CharsetUtils;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class MultipartRequest extends Request<String> {
    private MultipartEntityBuilder entity = MultipartEntityBuilder.create();
    private long fileLength = 0;
    private HttpEntity httpentity;
    private File mFilePart;
    private Listener<String> mListener;
    private MultipartProgressListener multipartProgressListener;
    private String token;

    public MultipartRequest(String url, File file, String token, MultipartProgressListener proListener, ErrorListener errorListener, Listener<String> listener) {
        super(1, url, errorListener);
        this.mListener = listener;
        this.mFilePart = file;
        this.fileLength = file.length();
        this.token = token;
        this.multipartProgressListener = proListener;
        this.entity.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
        try {
            this.entity.setCharset(CharsetUtils.get("UTF-8"));
        } catch (Exception | Error e) {
            e.printStackTrace(); Crashlytics.logException(e);

            buildMultipartEntity();
            this.httpentity = this.entity.build();
        }
        buildMultipartEntity();
        this.httpentity = this.entity.build();
    }

    private void buildMultipartEntity() {
        this.entity.addTextBody("api_token", this.token);
        this.entity.addPart("profile-picture", new FileBody(this.mFilePart, ContentType.create("image/*"), this.mFilePart.getName()));
    }

    public String getBodyContentType() {
        return this.httpentity.getContentType().getValue();
    }

    public byte[] getBody() {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try {
            this.httpentity.writeTo(new CountingOutputStream(bos, this.fileLength, this.multipartProgressListener));
        } catch (Exception|Error e) {
            e.printStackTrace(); Crashlytics.logException(e);

            return bos.toByteArray();
        }
        return bos.toByteArray();
    }

    protected Response<String> parseNetworkResponse(NetworkResponse response) {
        try {
            return Response.success(new String(response.data, "UTF-8"), getCacheEntry());
        } catch (Exception | Error e) {
            e.printStackTrace(); Crashlytics.logException(e);

            return Response.success(new String(response.data), getCacheEntry());
        }
    }

    protected void deliverResponse(String response) {
        this.mListener.onResponse(response);
    }

    public interface MultipartProgressListener {
        void transferred(long j, int i);
    }

    private static class CountingOutputStream extends FilterOutputStream {
        private final MultipartProgressListener progListener;
        private long fileLength;
        private long transferred = 0;

        public CountingOutputStream(OutputStream out, long fileLength, MultipartProgressListener listener) {
            super(out);
            this.fileLength = fileLength;
            this.progListener = listener;
        }

        public void write(byte[] b, int off, int len) throws IOException {
            this.out.write(b, off, len);
            if (this.progListener != null) {
                this.transferred += (long) len;
                if (this.fileLength != 0) {
                    this.progListener.transferred(this.transferred, (int) ((this.transferred * 100) / this.fileLength));
                }
            }
        }

        public void write(int b) throws IOException {
            this.out.write(b);
            if (this.progListener != null) {
                this.transferred++;
                if (this.fileLength != 0) {
                    this.progListener.transferred(this.transferred, (int) ((this.transferred * 100) / this.fileLength));
                }
            }
        }
    }
}


/*
public class MultipartRequest extends Request<String> {

    private MultipartEntityBuilder mBuilder = MultipartEntityBuilder.create();
    private final Response.Listener<String> mListener;
    private final File mImageFile;
    protected Map<String, String> headers;
    private String mBoundary;
    private Map<String, String> mParams;
    private String mFileFieldName;
    private String mFilename;
    private String mBodyContentType;

    public void setBoundary(String boundary) {
        this.mBoundary = boundary;
    }

    public MultipartRequest(String url, final Map<String, String> params, File imageFile, String filename, String fileFieldName, ErrorListener errorListener, Listener<String> listener) {
        super(Method.POST, url, errorListener);

        mListener = listener;
        mImageFile = imageFile;
        mParams = params;
        mFileFieldName = fileFieldName;
        mFilename = filename;

        buildMultipartEntity();
    }

    @Override
    public Map<String, String> getHeaders() throws AuthFailureError {
        Map<String, String> headers = super.getHeaders();

        if (headers == null || headers.equals(Collections.emptyMap())) {
            headers = new HashMap<String, String>();
        }

        headers.put("Accept", "application/json");
        headers.put("X-Requested-With", "XMLHTTPRequest");
        headers.put("User-Agent", "KaliMessenger");
        return headers;
    }

    private void buildMultipartEntity() {
        for (Map.Entry<String, String> entry : mParams.entrySet()) {
            mBuilder.addTextBody(entry.getKey(), entry.getValue());
        }
        mBuilder.addBinaryBody(mFileFieldName, mImageFile, ContentType.create("image/jpg"), mFilename);
        mBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
    }

    @Override
    public String getBodyContentType() {
        return mBodyContentType;
    }

    @Override
    public byte[] getBody() throws AuthFailureError {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try {
            HttpEntity entity = mBuilder.build();
            mBodyContentType = entity.getContentType().getValue();
            entity.writeTo(bos);
        } catch (IOException e) {
            VolleyLog.e("IOException writing to ByteArrayOutputStream bos, building the multipart request.");
        }

        return bos.toByteArray();
    }

    @Override
    protected void deliverResponse(String response) {
        mListener.onResponse(response);
    }

    @Override
    protected Response<String> parseNetworkResponse(NetworkResponse response) {
        String parsed;
        try {
            parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
        } catch (UnsupportedEncodingException e) {
            parsed = new String(response.data);
        }
        return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response));
    }
}*/