pencarianList){this.pencarianList = pencarianList;}
29 |
30 | public class ViewHolder extends RecyclerView.ViewHolder {
31 | public TextView namaKuliner;
32 | public TextView alamatKuliner;
33 | public TextView kategoriKuliner;
34 | public NetworkImageView imageKuliner;
35 |
36 | public ViewHolder(View itemView) {
37 | super(itemView);
38 | imageKuliner = (NetworkImageView)itemView.findViewById(R.id.image_kuliner);
39 | namaKuliner = (TextView) itemView.findViewById(R.id.nama_kuliner);
40 | alamatKuliner = (TextView) itemView.findViewById(R.id.alamat_kuliner);
41 | kategoriKuliner = (TextView) itemView.findViewById(R.id.kategori_kuliner);
42 | itemView.setOnClickListener(new View.OnClickListener() {
43 | @Override
44 | public void onClick(View v) {
45 | int position = getAdapterPosition();
46 |
47 | ModelPencarian modelPencarian = pencarianList.get(position);
48 | Intent intent = new Intent(v.getContext(), Detail.class);
49 | intent.putExtra("id_kuliner",modelPencarian.getIdKuliner());
50 | intent.putExtra("nama_kuliner",modelPencarian.getNamaKuliner());
51 | intent.putExtra("gambar_kuliner",modelPencarian.getFotoKuliner());
52 | intent.putExtra("kategori_kuliner",modelPencarian.getKategoriKuliner());
53 | intent.putExtra("alamat_kuliner",modelPencarian.getAlamatKuliner());
54 | intent.putExtra("latitude",modelPencarian.getLatitudeKuliner());
55 | intent.putExtra("longitude",modelPencarian.getLongitudeKuliner());
56 | v.getContext().startActivity(intent);
57 | }
58 | });
59 | }
60 | }
61 | @Override
62 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
63 | View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_pencarian, parent, false);
64 | ViewHolder vh = new ViewHolder(v);
65 | return vh;
66 | }
67 |
68 | @Override
69 | public void onBindViewHolder(ViewHolder holder, int position) {
70 | ModelPencarian item = pencarianList.get(position);
71 | if (imageLoader == null) imageLoader = AppController.getInstance().getImageLoader();
72 | holder.imageKuliner.setImageUrl(Constant.Image+item.getFotoKuliner(),imageLoader);
73 | holder.namaKuliner.setText(item.getNamaKuliner());
74 | holder.alamatKuliner.setText(item.getAlamatKuliner());
75 | holder.kategoriKuliner.setText(item.getKategoriKuliner());
76 | }
77 |
78 | @Override
79 | public int getItemCount() {
80 | return this.pencarianList.size();
81 | }
82 |
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_detail.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
20 |
21 |
28 |
29 |
30 |
31 |
42 |
43 |
51 |
59 |
60 |
61 |
62 |
69 |
70 |
73 |
78 |
79 |
80 |
81 |
88 |
89 |
92 |
93 |
98 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skripsi/anna/Logout.java:
--------------------------------------------------------------------------------
1 | package com.skripsi.anna;
2 |
3 | import android.content.Context;
4 | import android.net.Uri;
5 | import android.os.Bundle;
6 | import android.support.design.widget.Snackbar;
7 | import android.support.v4.app.Fragment;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 |
12 |
13 | /**
14 | * A simple {@link Fragment} subclass.
15 | * Activities that contain this fragment must implement the
16 | * {@link Logout.OnFragmentInteractionListener} interface
17 | * to handle interaction events.
18 | * Use the {@link Logout#newInstance} factory method to
19 | * create an instance of this fragment.
20 | */
21 | public class Logout extends Fragment {
22 | SessionManager session;
23 | // TODO: Rename parameter arguments, choose names that match
24 | // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
25 | private static final String ARG_PARAM1 = "param1";
26 | private static final String ARG_PARAM2 = "param2";
27 |
28 | // TODO: Rename and change types of parameters
29 | private String mParam1;
30 | private String mParam2;
31 |
32 | private OnFragmentInteractionListener mListener;
33 |
34 | public Logout() {
35 | // Required empty public constructor
36 | }
37 |
38 | /**
39 | * Use this factory method to create a new instance of
40 | * this fragment using the provided parameters.
41 | *
42 | * @param param1 Parameter 1.
43 | * @param param2 Parameter 2.
44 | * @return A new instance of fragment Logout.
45 | */
46 | // TODO: Rename and change types and number of parameters
47 | public static Logout newInstance(String param1, String param2) {
48 | Logout fragment = new Logout();
49 | Bundle args = new Bundle();
50 | args.putString(ARG_PARAM1, param1);
51 | args.putString(ARG_PARAM2, param2);
52 | fragment.setArguments(args);
53 | return fragment;
54 | }
55 |
56 | @Override
57 | public void onCreate(Bundle savedInstanceState) {
58 | super.onCreate(savedInstanceState);
59 | if (getArguments() != null) {
60 | mParam1 = getArguments().getString(ARG_PARAM1);
61 | mParam2 = getArguments().getString(ARG_PARAM2);
62 | }
63 | }
64 |
65 | @Override
66 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
67 | Bundle savedInstanceState) {
68 | View view = inflater.inflate(R.layout.fragment_logout, container, false);
69 | session = new SessionManager(view.getContext());
70 | session.logoutUser();
71 | Snackbar.make(view, "Silahkan Login untuk Mengatur Kuliner ", Snackbar.LENGTH_LONG).setAction("Action", null).show();
72 |
73 | return view;
74 | }
75 |
76 | // TODO: Rename method, update argument and hook method into UI event
77 | public void onButtonPressed(Uri uri) {
78 | if (mListener != null) {
79 | mListener.onFragmentInteraction(uri);
80 | }
81 | }
82 |
83 | @Override
84 | public void onAttach(Context context) {
85 | super.onAttach(context);
86 | if (context instanceof OnFragmentInteractionListener) {
87 | mListener = (OnFragmentInteractionListener) context;
88 | } else {
89 | throw new RuntimeException(context.toString()
90 | + " must implement OnFragmentInteractionListener");
91 | }
92 | }
93 |
94 | @Override
95 | public void onDetach() {
96 | super.onDetach();
97 | mListener = null;
98 | }
99 |
100 | /**
101 | * This interface must be implemented by activities that contain this
102 | * fragment to allow an interaction in this fragment to be communicated
103 | * to the activity and potentially other fragments contained in that
104 | * activity.
105 | *
106 | * See the Android Training lesson Communicating with Other Fragments for more information.
109 | */
110 | public interface OnFragmentInteractionListener {
111 | // TODO: Update argument type and name
112 | void onFragmentInteraction(Uri uri);
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skripsi/anna/MenuTambah.java:
--------------------------------------------------------------------------------
1 | package com.skripsi.anna;
2 |
3 | import android.content.Context;
4 | import android.net.Uri;
5 | import android.os.Bundle;
6 | import android.support.design.widget.Snackbar;
7 | import android.support.v4.app.Fragment;
8 | import android.support.v4.app.FragmentManager;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.Button;
13 | import android.widget.EditText;
14 |
15 | import com.android.volley.Request;
16 | import com.android.volley.RequestQueue;
17 | import com.android.volley.Response;
18 | import com.android.volley.VolleyError;
19 | import com.android.volley.toolbox.StringRequest;
20 | import com.android.volley.toolbox.Volley;
21 |
22 | import java.util.HashMap;
23 | import java.util.Map;
24 |
25 |
26 | public class MenuTambah extends Fragment {
27 | private String idKuliner;
28 | EditText NamaMenu, HargaMenu;
29 | Button Tambah;
30 |
31 | private OnFragmentInteractionListener mListener;
32 |
33 | public MenuTambah() {
34 | }
35 | public static MenuTambah newInstance(String idKuliner) {
36 | MenuTambah fragment = new MenuTambah();
37 | Bundle args = new Bundle();
38 | args.putString("id_kuliner", idKuliner);
39 | fragment.setArguments(args);
40 | return fragment;
41 | }
42 |
43 | @Override
44 | public void onCreate(Bundle savedInstanceState) {
45 | super.onCreate(savedInstanceState);
46 | if (getArguments() != null) {
47 | idKuliner = getArguments().getString("id_kuliner");
48 | }
49 | }
50 |
51 | @Override
52 | public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
53 | View view = inflater.inflate(R.layout.fragment_menu_tambah, container, false);
54 | NamaMenu = (EditText) view.findViewById(R.id.NamaMenu);
55 | HargaMenu = (EditText) view.findViewById(R.id.HargaMenu);
56 | Tambah = (Button) view.findViewById(R.id.Tambah);
57 | Tambah.setOnClickListener(new View.OnClickListener() {
58 | @Override
59 | public void onClick(final View v) {
60 | StringRequest stringRequest = new StringRequest(Request.Method.POST, Constant.Kuliner,
61 | new Response.Listener() {
62 | @Override
63 | public void onResponse(String response) {
64 | Menu menu = new Menu();
65 | FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
66 | fragmentManager.beginTransaction().replace(R.id.flContent, menu).commit();
67 | Snackbar.make(v, "Menu Sudah Ditambahkan", Snackbar.LENGTH_LONG).setAction("Action", null).show();
68 | }
69 | },
70 | new Response.ErrorListener() {
71 | @Override
72 | public void onErrorResponse(VolleyError error) {
73 | Snackbar.make(v, "Terjadi Galat", Snackbar.LENGTH_LONG).setAction("Action", null).show();
74 | }
75 | }
76 | ) {
77 | @Override
78 | public String getBodyContentType() {
79 | return "application/x-www-form-urlencoded";
80 | }
81 |
82 | protected Map getParams() {
83 | Map params = new HashMap();
84 | params.put("id_kuliner",idKuliner);
85 | params.put("nama_menu",NamaMenu.getText().toString());
86 | params.put("harga_menu",HargaMenu.getText().toString());
87 | return params;
88 | }
89 | };
90 | RequestQueue requestQueue = Volley.newRequestQueue(v.getContext());
91 | requestQueue.add(stringRequest);
92 | }
93 | });
94 |
95 | return view;
96 | }
97 | public void onButtonPressed(Uri uri) {
98 | if (mListener != null) {
99 | mListener.onFragmentInteraction(uri);
100 | }
101 | }
102 |
103 | @Override
104 | public void onAttach(Context context) {
105 | super.onAttach(context);
106 | if (context instanceof OnFragmentInteractionListener) {
107 | mListener = (OnFragmentInteractionListener) context;
108 | } else {
109 | throw new RuntimeException(context.toString()
110 | + " must implement OnFragmentInteractionListener");
111 | }
112 | }
113 |
114 | @Override
115 | public void onDetach() {
116 | super.onDetach();
117 | mListener = null;
118 | }
119 |
120 | public interface OnFragmentInteractionListener {
121 | void onFragmentInteraction(Uri uri);
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skripsi/anna/SessionManager.java:
--------------------------------------------------------------------------------
1 | package com.skripsi.anna;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.content.SharedPreferences;
6 | import android.content.SharedPreferences.Editor;
7 |
8 | import com.android.volley.Request;
9 | import com.android.volley.RequestQueue;
10 | import com.android.volley.Response;
11 | import com.android.volley.VolleyError;
12 | import com.android.volley.toolbox.StringRequest;
13 | import com.android.volley.toolbox.Volley;
14 |
15 | import org.json.JSONArray;
16 | import org.json.JSONException;
17 | import org.json.JSONObject;
18 |
19 | import java.util.HashMap;
20 |
21 | /**
22 | * Created by gandhi on 6/12/17.
23 | */
24 |
25 | public class SessionManager {
26 | SharedPreferences pref;
27 | Editor editor;
28 | Context _context;
29 | int PRIVATE_MODE = 0;
30 | private static final String PREF_NAME = "KulinerPref";
31 | private static final String IS_LOGIN = "IsLoggedIn";
32 | public static final String KEY_NAME = "namaKey";
33 | public static final String KEY_EMAIL = "emailKey";
34 | public static final String KEY_ID = "idKey";
35 | public static final String KEY_HP = "hpKey";
36 | public static final String KEY_PASSWORD = "pwdKey";
37 |
38 | public SessionManager(Context context){
39 | this._context = context;
40 | pref = _context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
41 | editor = pref.edit();
42 | }
43 |
44 | public void createLoginSession(String name, String email, String id, String hp, String password){
45 | editor.putBoolean(IS_LOGIN, true);
46 | editor.putString(KEY_NAME, name);
47 | editor.putString(KEY_EMAIL, email);
48 | editor.putString(KEY_ID, id);
49 | editor.putString(KEY_HP, hp);
50 | editor.putString(KEY_PASSWORD, password);
51 | editor.commit();
52 | }
53 |
54 | public void checkLogin(){
55 | if(!this.isLoggedIn()){
56 | Intent i = new Intent(_context, Login.class);
57 | i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
58 | i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
59 | _context.startActivity(i);
60 | }
61 | else{
62 | HashMap user = this.getUserDetails();
63 | String password = user.get(SessionManager.KEY_PASSWORD);
64 | String email = user.get(SessionManager.KEY_EMAIL);
65 |
66 | StringRequest stringRequest = new StringRequest(Request.Method.GET, Constant.CekLogin+"email="+email+"&password="+password,
67 | new Response.Listener() {
68 | @Override
69 | public void onResponse(String response) {
70 | try {
71 | JSONArray jsonArray = new JSONArray(response);
72 | for (int i=0;i getUserDetails(){
103 | HashMap user = new HashMap();
104 | user.put(KEY_NAME, pref.getString(KEY_NAME, null));
105 | user.put(KEY_EMAIL, pref.getString(KEY_EMAIL, null));
106 | user.put(KEY_ID, pref.getString(KEY_ID, null));
107 | user.put(KEY_HP, pref.getString(KEY_HP, null));
108 | user.put(KEY_PASSWORD, pref.getString(KEY_PASSWORD, null));
109 | return user;
110 | }
111 |
112 | public void logoutUser(){
113 | editor.clear();
114 | editor.commit();
115 |
116 | Intent i = new Intent(_context, Login.class);
117 | i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
118 | i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
119 | _context.startActivity(i);
120 | }
121 | public boolean isLoggedIn(){
122 | return pref.getBoolean(IS_LOGIN, false);
123 | }
124 |
125 | }
126 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skripsi/anna/DataParser.java:
--------------------------------------------------------------------------------
1 | package com.skripsi.anna;
2 |
3 | /**
4 | * Created by gandhi on 6/4/17.
5 | */
6 |
7 | import com.google.android.gms.maps.model.LatLng;
8 |
9 | import org.json.JSONArray;
10 | import org.json.JSONException;
11 | import org.json.JSONObject;
12 |
13 | import java.util.ArrayList;
14 | import java.util.HashMap;
15 | import java.util.List;
16 |
17 | public class DataParser {
18 |
19 | public List>> parsing(JSONObject jsonObject){
20 | List>> disdur = new ArrayList<>();
21 | JSONArray jRoutes;
22 | JSONArray jLegs;
23 | JSONArray jSteps;
24 |
25 | try {
26 | jRoutes = jsonObject.getJSONArray("routes");
27 | for(int i=0;i();
30 | for(int j=0;j hm = new HashMap<>();
35 | JSONObject dis = jObj.getJSONObject("distance");
36 | JSONObject dur = jObj.getJSONObject("duration");
37 | hm.put("disVal", dis.getString("value"));
38 | hm.put("disText", dis.getString("text"));
39 | hm.put("durVal", dur.getString("value"));
40 | hm.put("durText", dur.getString("text"));
41 | path.add(hm);
42 | }
43 | }
44 | disdur.add(path);
45 | }
46 |
47 | } catch (JSONException e) {
48 | e.printStackTrace();
49 | }
50 |
51 |
52 | return disdur;
53 | }
54 |
55 |
56 | /** Receives a JSONObject and returns a list of lists containing latitude and longitude */
57 | public List>> parse(JSONObject jObject){
58 |
59 | List>> routes = new ArrayList<>() ;
60 | JSONArray jRoutes;
61 | JSONArray jLegs;
62 | JSONArray jSteps;
63 |
64 | try {
65 |
66 | jRoutes = jObject.getJSONArray("routes");
67 |
68 | /** Traversing all routes */
69 | for(int i=0;i();
72 |
73 | /** Traversing all legs */
74 | for(int j=0;j list = decodePoly(polyline);
83 |
84 | /** Traversing all points */
85 | for(int l=0;l hm = new HashMap<>();
87 | hm.put("lat", Double.toString((list.get(l)).latitude) );
88 | hm.put("lng", Double.toString((list.get(l)).longitude) );
89 | path.add(hm);
90 | }
91 | }
92 | routes.add(path);
93 | }
94 | }
95 |
96 | } catch (JSONException e) {
97 | e.printStackTrace();
98 | }catch (Exception e){
99 | }
100 |
101 | return routes;
102 | }
103 |
104 |
105 | /**
106 | * Method to decode polyline points
107 | * Courtesy : http://jeffreysambells.com/2010/05/27/decoding-polylines-from-google-maps-direction-api-with-java
108 | * */
109 | private List decodePoly(String encoded) {
110 |
111 | List poly = new ArrayList<>();
112 | int index = 0, len = encoded.length();
113 | int lat = 0, lng = 0;
114 |
115 | while (index < len) {
116 | int b, shift = 0, result = 0;
117 | do {
118 | b = encoded.charAt(index++) - 63;
119 | result |= (b & 0x1f) << shift;
120 | shift += 5;
121 | } while (b >= 0x20);
122 | int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
123 | lat += dlat;
124 |
125 | shift = 0;
126 | result = 0;
127 | do {
128 | b = encoded.charAt(index++) - 63;
129 | result |= (b & 0x1f) << shift;
130 | shift += 5;
131 | } while (b >= 0x20);
132 | int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
133 | lng += dlng;
134 |
135 | LatLng p = new LatLng((((double) lat / 1E5)),
136 | (((double) lng / 1E5)));
137 | poly.add(p);
138 | }
139 |
140 | return poly;
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_menu_tambah.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
15 |
16 |
24 |
29 |
30 |
37 |
41 |
48 |
49 |
50 |
56 |
57 |
64 |
65 |
74 |
75 |
81 |
82 |
89 |
90 |
99 |
100 |
101 |
102 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
24 |
25 |
26 |
33 |
37 |
44 |
45 |
46 |
52 |
53 |
60 |
61 |
70 |
71 |
77 |
78 |
85 |
86 |
95 |
96 |
97 |
106 |
107 |
110 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skripsi/anna/Login.java:
--------------------------------------------------------------------------------
1 | package com.skripsi.anna;
2 |
3 | import android.app.ProgressDialog;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.design.widget.Snackbar;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.view.View;
9 | import android.widget.Button;
10 | import android.widget.EditText;
11 | import android.widget.TextView;
12 |
13 | import com.android.volley.Request;
14 | import com.android.volley.RequestQueue;
15 | import com.android.volley.Response;
16 | import com.android.volley.VolleyError;
17 | import com.android.volley.toolbox.StringRequest;
18 | import com.android.volley.toolbox.Volley;
19 |
20 | import org.json.JSONArray;
21 | import org.json.JSONException;
22 | import org.json.JSONObject;
23 |
24 | public class Login extends AppCompatActivity {
25 | EditText Email,Password;
26 | Button Login;
27 | TextView Daftar;
28 | ProgressDialog progressDialog;
29 | SessionManager session;
30 |
31 | @Override
32 | protected void onCreate(Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | setContentView(R.layout.activity_login);
35 | session = new SessionManager(getApplicationContext());
36 | Email = (EditText) findViewById(R.id.Email);
37 | Password = (EditText) findViewById(R.id.Password);
38 | Login = (Button) findViewById(R.id.Login);
39 | Login.setOnClickListener(new View.OnClickListener() {
40 | @Override
41 | public void onClick(View v) {
42 | Login(Email.getText().toString(),Password.getText().toString());
43 | }
44 | });
45 | Daftar = (TextView) findViewById(R.id.Daftar);
46 | Daftar.setOnClickListener(new View.OnClickListener() {
47 | @Override
48 | public void onClick(View v) {
49 | Intent intent = new Intent(getBaseContext(),Daftar.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
50 | startActivity(intent);
51 | }
52 | });
53 | }
54 | @Override
55 | public void onBackPressed() {
56 | Intent intent = new Intent(this,MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
57 | startActivity(intent);
58 | }
59 |
60 | private void Login(String Email,String Password){
61 | progressDialog = ProgressDialog.show(this,"Log in . .","Auth . .",true);
62 | if (!validate()) {
63 | onLoginFailed();
64 | return;
65 | }
66 | StringRequest stringRequest = new StringRequest(Request.Method.GET, Constant.Login +"email="+Email+"&password="+Password, new Response.Listener() {
67 | @Override
68 | public void onResponse(String response) {
69 | try {
70 | JSONArray jsonArray = new JSONArray(response);
71 | for (int i=0;i modelMenus = new ArrayList();
37 |
38 | Button peta;
39 | TextView namaKuliner,kategoriKuliner,alamatKuliner;
40 | NetworkImageView imageKuliner;
41 | ImageLoader imageLoader = AppController.getInstance().getImageLoader();
42 |
43 |
44 | @Override
45 | protected void onCreate(Bundle savedInstanceState) {
46 | super.onCreate(savedInstanceState);
47 | setContentView(R.layout.activity_detail);
48 | final Bundle b = getIntent().getExtras();
49 | GetMenuByIdKuliner(b.getString("id_kuliner"));
50 |
51 | peta = (Button) findViewById(R.id.button);
52 | peta.setOnClickListener(new View.OnClickListener() {
53 | @Override
54 | public void onClick(View v) {
55 | Intent intent = new Intent(getApplicationContext(),MapsActivity.class);
56 | intent.putExtra("id_kuliner",b.getString("id_kuliner"));
57 | intent.putExtra("longitude",b.getString("longitude"));
58 | intent.putExtra("latitude",b.getString("latitude"));
59 | intent.putExtra("title",b.getString("nama_kuliner"));
60 | intent.putExtra("snippet",b.getString("kategori_kuliner") +" : "+b.getString("alamat_kuliner"));
61 | startActivity(intent);
62 | }
63 | });
64 | imageKuliner = (NetworkImageView) findViewById(R.id.image_kuliner);
65 | namaKuliner = (TextView) findViewById(R.id.nama_kuliner);
66 | kategoriKuliner = (TextView) findViewById(R.id.kategori_kuliner);
67 | alamatKuliner = (TextView) findViewById(R.id.alamat_kuliner);
68 | rv_barang = (RecyclerView) findViewById(R.id.rv_barang);
69 | rv_barang.setHasFixedSize(true);
70 |
71 | imageKuliner.setImageUrl(Constant.Image+b.getString("gambar_kuliner"),imageLoader);
72 | namaKuliner.setText(b.getString("nama_kuliner"));
73 | kategoriKuliner.setText(b.getString("kategori_kuliner"));
74 | alamatKuliner.setText(b.getString("alamat_kuliner"));
75 |
76 | lmBarang = new LinearLayoutManager(this);
77 | rv_barang.setLayoutManager(lmBarang);
78 | adapter = new Barang(modelMenus);
79 | rv_barang.setAdapter(adapter);
80 | }
81 | private void GetMenuByIdKuliner( String IdKuliner){
82 | StringRequest stringRequest = new StringRequest(Method.GET, Constant.GetMenu + IdKuliner, new Response.Listener() {
83 | @Override
84 | public void onResponse(String response) {
85 | try {
86 | JSONArray jsonArray = new JSONArray(response);
87 | for (int i=0;i \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_menu_edit.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
15 |
16 |
24 |
29 |
30 |
37 |
41 |
48 |
49 |
50 |
56 |
57 |
64 |
65 |
74 |
75 |
81 |
82 |
89 |
90 |
99 |
100 |
101 |
102 |
111 |
112 |
115 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skripsi/anna/Daftar.java:
--------------------------------------------------------------------------------
1 | package com.skripsi.anna;
2 |
3 | import android.app.ProgressDialog;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.design.widget.Snackbar;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.view.View;
9 | import android.widget.Button;
10 | import android.widget.EditText;
11 |
12 | import com.android.volley.Request;
13 | import com.android.volley.RequestQueue;
14 | import com.android.volley.Response;
15 | import com.android.volley.VolleyError;
16 | import com.android.volley.toolbox.StringRequest;
17 | import com.android.volley.toolbox.Volley;
18 |
19 | import org.json.JSONArray;
20 | import org.json.JSONException;
21 | import org.json.JSONObject;
22 |
23 | import java.util.HashMap;
24 | import java.util.Map;
25 |
26 | public class Daftar extends AppCompatActivity {
27 | EditText Nama,Email,Hp,Password,RePassword;
28 | Button Daftar;
29 | ProgressDialog progressDialog;
30 | @Override
31 | protected void onCreate(Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | setContentView(R.layout.activity_daftar);
34 | Nama = (EditText) findViewById(R.id.Nama);
35 | Email = (EditText) findViewById(R.id.Email);
36 | Hp = (EditText) findViewById(R.id.Hp);
37 | Password = (EditText) findViewById(R.id.Password);
38 | RePassword = (EditText) findViewById(R.id.RePassword);
39 | Daftar = (Button) findViewById(R.id.Daftar);
40 | Daftar.setOnClickListener(new View.OnClickListener() {
41 | @Override
42 | public void onClick(final View v) {
43 | if (!validate()) {
44 | onDaftarFailed("Gagal Mendaftar");
45 | return;
46 | }
47 | progressDialog = ProgressDialog.show(v.getContext(),"Mendaftar","Auth . .",true);
48 | StringRequest stringRequest = new StringRequest(Request.Method.POST, Constant.Daftar, new Response.Listener() {
49 | @Override
50 | public void onResponse(String response) {
51 | try {
52 | JSONArray jsonArray = new JSONArray(response);
53 | for (int i=0;i getParams() {
81 | Map params = new HashMap();
82 | params.put("nama_user", Nama.getText().toString());
83 | params.put("email_user", Email.getText().toString());
84 | params.put("hp_user", Hp.getText().toString());
85 | params.put("password_user", RePassword.getText().toString());
86 | return params;
87 | }
88 | };
89 | RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
90 | requestQueue.add(stringRequest);
91 |
92 | }
93 | });
94 | }
95 | public void onDaftarFailed(String pesan) {
96 | Snackbar.make(getCurrentFocus(), pesan, Snackbar.LENGTH_LONG).setAction("Action", null).show();
97 | Daftar.setEnabled(true);
98 | }
99 | public boolean validate() {
100 | boolean valid = true;
101 |
102 | String nama = Nama.getText().toString();
103 | String email = Email.getText().toString();
104 | String password = Password.getText().toString();
105 | String repassword = RePassword.getText().toString();
106 |
107 | if (email.isEmpty() ) {
108 | Email.setError("Email Tidak Boleh Kosong");
109 | valid = false;
110 | } else {
111 | Email.setError(null);
112 | }
113 | if (nama.isEmpty() ) {
114 | Nama.setError("Nama Tidak Boleh Kosong");
115 | valid = false;
116 | } else {
117 | Nama.setError(null);
118 | }
119 |
120 | if (password.isEmpty() ) {
121 | Password.setError("Password Tidak Boleh Kosong");
122 | valid = false;
123 | } else {
124 | Password.setError(null);
125 | }
126 |
127 | if(repassword.isEmpty()){
128 | RePassword.setError("Password Tidak Boleh Kosong");
129 | valid = false;
130 | }else {
131 | RePassword.setError(null);
132 | }
133 |
134 | if(password.equals(repassword)){
135 |
136 | }
137 | else{
138 | RePassword.setError("Password Tidak Sesuai");
139 | valid = false;
140 | }
141 |
142 |
143 | return valid;
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_user.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
14 |
15 |
23 |
28 |
29 |
36 |
39 |
46 |
47 |
48 |
54 |
55 |
62 |
63 |
72 |
73 |
79 |
80 |
87 |
88 |
97 |
98 |
104 |
105 |
112 |
113 |
122 |
123 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_password.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
16 |
17 |
25 |
30 |
31 |
38 |
42 |
49 |
50 |
51 |
57 |
58 |
65 |
66 |
75 |
76 |
82 |
83 |
90 |
91 |
100 |
101 |
107 |
108 |
115 |
116 |
125 |
126 |
127 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_kuliner.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
14 |
15 |
23 |
28 |
29 |
36 |
40 |
41 |
49 |
50 |
51 |
57 |
58 |
65 |
66 |
75 |
76 |
82 |
83 |
90 |
91 |
100 |
101 |
107 |
108 |
115 |
116 |
125 |
126 |
127 |
135 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skripsi/anna/MainAdmin.java:
--------------------------------------------------------------------------------
1 | package com.skripsi.anna;
2 |
3 | import android.content.Intent;
4 | import android.net.Uri;
5 | import android.os.Bundle;
6 | import android.support.design.widget.NavigationView;
7 | import android.support.design.widget.Snackbar;
8 | import android.support.v4.app.Fragment;
9 | import android.support.v4.app.FragmentManager;
10 | import android.support.v4.view.GravityCompat;
11 | import android.support.v4.widget.DrawerLayout;
12 | import android.support.v7.app.ActionBarDrawerToggle;
13 | import android.support.v7.app.AppCompatActivity;
14 | import android.support.v7.widget.Toolbar;
15 | import android.view.MenuItem;
16 | import android.view.View;
17 | import android.widget.TextView;
18 |
19 | import com.android.volley.Request;
20 | import com.android.volley.RequestQueue;
21 | import com.android.volley.Response;
22 | import com.android.volley.VolleyError;
23 | import com.android.volley.toolbox.StringRequest;
24 | import com.android.volley.toolbox.Volley;
25 |
26 | import org.json.JSONArray;
27 | import org.json.JSONException;
28 | import org.json.JSONObject;
29 |
30 | import java.util.HashMap;
31 |
32 | public class MainAdmin extends AppCompatActivity implements
33 | MenuTambah.OnFragmentInteractionListener,
34 | MenuEdit.OnFragmentInteractionListener,
35 | My.OnFragmentInteractionListener,
36 | Logout.OnFragmentInteractionListener,
37 | User.OnFragmentInteractionListener,
38 | Password.OnFragmentInteractionListener,
39 | Menu.OnFragmentInteractionListener,
40 | Kuliner.OnFragmentInteractionListener,
41 | NavigationView.OnNavigationItemSelectedListener {
42 |
43 |
44 | TextView NamaKuliner,AlamatKuliner;
45 | SessionManager session;
46 |
47 | @Override
48 | protected void onCreate(Bundle savedInstanceState) {
49 | super.onCreate(savedInstanceState);
50 | setContentView(R.layout.activity_main_admin);
51 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
52 | setSupportActionBar(toolbar);
53 |
54 | if (savedInstanceState == null) {
55 | Fragment fragment = null;
56 | Class fragmentClass = null;
57 | fragmentClass = Kuliner.class;
58 | try {
59 | fragment = (Fragment) fragmentClass.newInstance();
60 | } catch (Exception e) {
61 | e.printStackTrace();
62 | }
63 |
64 | FragmentManager fragmentManager = getSupportFragmentManager();
65 | fragmentManager.beginTransaction().replace(R.id.flContent, fragment).commit();
66 | }
67 |
68 | session = new SessionManager(getApplicationContext());
69 | session.checkLogin();
70 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
71 | ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
72 | drawer.setDrawerListener(toggle);
73 | toggle.syncState();
74 |
75 | NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
76 | View view = navigationView.getHeaderView(0);
77 | NamaKuliner = (TextView) view.findViewById(R.id.NamaKuliner);
78 | AlamatKuliner = (TextView) view.findViewById(R.id.AlamatKuliner);
79 | navigationView.setNavigationItemSelectedListener(this);
80 | GetKuliner();
81 | }
82 |
83 |
84 | @Override
85 | public void onBackPressed() {
86 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
87 | if (drawer.isDrawerOpen(GravityCompat.START)) {
88 | drawer.closeDrawer(GravityCompat.START);
89 | } else {
90 | Intent intent = new Intent(this,MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
91 | startActivity(intent);
92 | }
93 | }
94 |
95 |
96 | @SuppressWarnings("StatementWithEmptyBody")
97 | @Override
98 | public boolean onNavigationItemSelected(MenuItem item) {
99 | int id = item.getItemId();
100 | Fragment fragment = null;
101 | Class fragmentClass = null;
102 | if (id == R.id.nav_kuliner) {
103 | fragmentClass = Kuliner.class;
104 | }else if (id == R.id.nav_user) {
105 | fragmentClass = User.class;
106 | }else if (id == R.id.nav_menu) {
107 | fragmentClass = Menu.class;
108 | }else if (id == R.id.nav_password) {
109 | fragmentClass = Password.class;
110 | }else if (id == R.id.nav_logout) {
111 | fragmentClass = Logout.class;
112 | }else if (id == R.id.nav_maps) {
113 | fragmentClass = My.class;
114 | }
115 |
116 | try {
117 | fragment = (Fragment) fragmentClass.newInstance();
118 | } catch (Exception e) {
119 | e.printStackTrace();
120 | }
121 | FragmentManager fragmentManager = getSupportFragmentManager();
122 | fragmentManager.beginTransaction().replace(R.id.flContent, fragment).commit();
123 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
124 | drawer.closeDrawer(GravityCompat.START);
125 | return true;
126 | }
127 | public void jump(){
128 | Fragment fragment = null;
129 | Class fragmentClass = null;
130 | fragmentClass = MenuEdit.class;
131 | try {
132 | fragment = (Fragment) fragmentClass.newInstance();
133 | } catch (Exception e) {
134 | e.printStackTrace();
135 | }
136 | FragmentManager fragmentManager = getSupportFragmentManager();
137 | fragmentManager.beginTransaction().replace(R.id.flContent, fragment).commit();
138 | }
139 | private void GetKuliner(){
140 | HashMap user = session.getUserDetails();
141 | String id = user.get(SessionManager.KEY_ID);
142 | StringRequest stringRequest = new StringRequest(Request.Method.GET, Constant.GetByIdUser+id,
143 | new Response.Listener() {
144 | @Override
145 | public void onResponse(String response) {
146 | try {
147 | JSONArray jsonArray = new JSONArray(response);
148 | for (int i=0;i
2 |
10 |
11 |
19 |
24 |
25 |
32 |
35 |
42 |
43 |
44 |
50 |
51 |
58 |
59 |
68 |
69 |
75 |
76 |
83 |
84 |
93 |
94 |
100 |
101 |
108 |
109 |
118 |
119 |
125 |
126 |
133 |
134 |
143 |
144 |
150 |
151 |
158 |
159 |
168 |
169 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skripsi/anna/Menu.java:
--------------------------------------------------------------------------------
1 | package com.skripsi.anna;
2 |
3 | import android.content.Context;
4 | import android.net.Uri;
5 | import android.os.Bundle;
6 | import android.support.design.widget.FloatingActionButton;
7 | import android.support.design.widget.Snackbar;
8 | import android.support.v4.app.Fragment;
9 | import android.support.v4.app.FragmentManager;
10 | import android.support.v7.widget.LinearLayoutManager;
11 | import android.support.v7.widget.RecyclerView;
12 | import android.view.LayoutInflater;
13 | import android.view.View;
14 | import android.view.ViewGroup;
15 |
16 | import com.android.volley.Request;
17 | import com.android.volley.RequestQueue;
18 | import com.android.volley.Response;
19 | import com.android.volley.VolleyError;
20 | import com.android.volley.toolbox.StringRequest;
21 | import com.android.volley.toolbox.Volley;
22 | import com.skripsi.anna.adapter.BarangEditor;
23 | import com.skripsi.anna.model.ModelMenu;
24 |
25 | import org.json.JSONArray;
26 | import org.json.JSONException;
27 | import org.json.JSONObject;
28 |
29 | import java.util.ArrayList;
30 | import java.util.HashMap;
31 | import java.util.List;
32 |
33 |
34 | public class Menu extends Fragment {
35 | private RecyclerView rv_barang;
36 | private RecyclerView.Adapter adapter;
37 | private RecyclerView.LayoutManager lmBarang;
38 | private List modelMenus = new ArrayList();
39 | SessionManager session;
40 | String idKuliner;
41 |
42 |
43 | private static final String ARG_PARAM1 = "param1";
44 | private static final String ARG_PARAM2 = "param2";
45 | private String mParam1;
46 | private String mParam2;
47 |
48 | private OnFragmentInteractionListener mListener;
49 |
50 | public Menu() {
51 | }
52 | public static Menu newInstance(String param1, String param2) {
53 | Menu fragment = new Menu();
54 | Bundle args = new Bundle();
55 | args.putString(ARG_PARAM1, param1);
56 | args.putString(ARG_PARAM2, param2);
57 | fragment.setArguments(args);
58 | return fragment;
59 | }
60 |
61 | @Override
62 | public void onCreate(Bundle savedInstanceState) {
63 | super.onCreate(savedInstanceState);
64 | if (getArguments() != null) {
65 | mParam1 = getArguments().getString(ARG_PARAM1);
66 | mParam2 = getArguments().getString(ARG_PARAM2);
67 | }
68 | }
69 |
70 | @Override
71 | public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
72 | View view = inflater.inflate(R.layout.fragment_menu, container, false);
73 | session = new SessionManager(view.getContext());
74 | final HashMap user = session.getUserDetails();
75 |
76 | GetIdKuliner(user.get(SessionManager.KEY_ID));
77 |
78 | rv_barang = (RecyclerView) view.findViewById(R.id.rv_barang);
79 | rv_barang.setHasFixedSize(true);
80 | lmBarang = new LinearLayoutManager(getActivity());
81 | rv_barang.setLayoutManager(lmBarang);
82 | adapter = new BarangEditor(modelMenus);
83 | rv_barang.setAdapter(adapter);
84 | FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.fab);
85 | fab.setOnClickListener(new View.OnClickListener() {
86 | @Override
87 | public void onClick(View view) {
88 | MenuTambah menuTambah = new MenuTambah();
89 | Bundle bundle = new Bundle();
90 | System.out.println(idKuliner);
91 | bundle.putString("id_kuliner",idKuliner);
92 | menuTambah.setArguments(bundle);
93 | FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
94 | fragmentManager.beginTransaction().replace(R.id.flContent, menuTambah).commit();
95 | }
96 | });
97 | return view;
98 | }
99 | public void onButtonPressed(Uri uri) {
100 | if (mListener != null) {
101 | mListener.onFragmentInteraction(uri);
102 | }
103 | }
104 |
105 | @Override
106 | public void onAttach(Context context) {
107 | super.onAttach(context);
108 | if (context instanceof OnFragmentInteractionListener) {
109 | mListener = (OnFragmentInteractionListener) context;
110 | } else {
111 | throw new RuntimeException(context.toString()
112 | + " must implement OnFragmentInteractionListener");
113 | }
114 | }
115 |
116 | @Override
117 | public void onDetach() {
118 | super.onDetach();
119 | mListener = null;
120 | }
121 | public interface OnFragmentInteractionListener {
122 | void onFragmentInteraction(Uri uri);
123 | }
124 | private void GetIdKuliner(final String idUser){
125 | StringRequest stringRequest = new StringRequest(Request.Method.GET, Constant.GetByIdUser+idUser,
126 | new Response.Listener() {
127 | @Override
128 | public void onResponse(String response) {
129 | try {
130 | JSONArray jsonArray = new JSONArray(response);
131 | for (int i=0;i() {
158 | @Override
159 | public void onResponse(String response) {
160 | try {
161 | JSONArray jsonArray = new JSONArray(response);
162 | for (int i=0;i modelPencarian = new ArrayList();
37 |
38 |
39 | @Override
40 | protected void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 | setContentView(R.layout.activity_main);
43 | StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
44 | StrictMode.setThreadPolicy(policy);
45 | GetData();
46 | rvView = (RecyclerView) findViewById(R.id.rv_main);
47 | rvView.setHasFixedSize(true);
48 | layoutManager = new LinearLayoutManager(this);
49 | rvView.setLayoutManager(layoutManager);
50 | adapter = new Pencarian(modelPencarian);
51 | rvView.setAdapter(adapter);
52 |
53 | }
54 |
55 | public boolean onCreateOptionsMenu(Menu menu) {
56 | MenuInflater inflater = getMenuInflater();
57 | inflater.inflate(R.menu.menu_search, menu);
58 |
59 | MenuItem searchItem = menu.findItem(R.id.search);
60 | final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
61 | searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
62 | @Override
63 | public boolean onQueryTextSubmit(String query) {
64 |
65 | Cari(query.replace(" ", "%20"));
66 | return false;
67 | }
68 |
69 | @Override
70 | public boolean onQueryTextChange(String newText) {
71 | Cari(newText.replace(" ","%20"));
72 | return false;
73 | }
74 | });
75 | return super.onCreateOptionsMenu(menu);
76 | }
77 | @Override
78 | public boolean onOptionsItemSelected(MenuItem item) {
79 | int id = item.getItemId();
80 | if (id == R.id.login) {
81 | Intent intent = new Intent(this,MainAdmin.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
82 | startActivity(intent);
83 | return true;
84 | }
85 | return super.onOptionsItemSelected(item);
86 | }
87 | @Override
88 | public void onBackPressed() {
89 | moveTaskToBack(true);
90 | }
91 |
92 | private void Cari(String keyword){
93 | StringRequest stringRequest = new StringRequest(Request.Method.GET, Constant.CariKuliner+keyword,
94 | new Response.Listener() {
95 | @Override
96 | public void onResponse(String response) {
97 | try {
98 | JSONArray jsonArray = new JSONArray(response);
99 | modelPencarian.clear();
100 | for (int i=0;i() {
136 | @Override
137 | public void onResponse(String response) {
138 | try {
139 | JSONArray jsonArray = new JSONArray(response);
140 | modelPencarian.clear();
141 | for (int i=0;i user = session.getUserDetails();
88 | OldPassword = (EditText) view.findViewById(R.id.OldPassword);
89 | NewPassword = (EditText) view.findViewById(R.id.NewPassword);
90 | RePassword = (EditText) view.findViewById(R.id.RePassword);
91 | Update = (Button) view.findViewById(R.id.Update);
92 | Update.setOnClickListener(new View.OnClickListener() {
93 | @Override
94 | public void onClick(final View v) {
95 | if(!validate()){
96 | return;
97 | }
98 | else {
99 | StringRequest stringRequest = new StringRequest(Request.Method.PUT, Constant.Login, new Response.Listener() {
100 | @Override
101 | public void onResponse(String response) {
102 |
103 | try {
104 | JSONArray jsonArray = new JSONArray(response);
105 | for (int i=0;i getParams() {
137 | Map params = new HashMap();
138 | params.put("pwd", "y");
139 | params.put("id_user",user.get(SessionManager.KEY_ID));
140 | params.put("old_password",OldPassword.getText().toString());
141 | params.put("password_user", RePassword.getText().toString());
142 | return params;
143 | }
144 | };
145 | RequestQueue requestQueue = Volley.newRequestQueue(view.getContext());
146 | requestQueue.add(stringRequest);
147 | }
148 |
149 | }
150 | });
151 | return view;
152 | }
153 |
154 | public boolean validate() {
155 | boolean valid = true;
156 |
157 | String old = OldPassword.getText().toString();
158 | String newPassword = NewPassword.getText().toString();
159 | String rePassword = RePassword.getText().toString();
160 | if(old.isEmpty()){
161 | OldPassword.setError("Password tidak boleh kosong");
162 | }else {
163 | OldPassword.setError(null);
164 | }
165 | if(!newPassword.equals(rePassword)){
166 | RePassword.setError("Password tidak Cocok");
167 | }else {
168 | RePassword.setError(null);
169 | }
170 | if(old.equals(newPassword)){
171 | NewPassword.setError("Password sama dengan sebelumnya");
172 | }else {
173 | NewPassword.setError(null);
174 | }
175 |
176 | return valid;
177 | }
178 |
179 | // TODO: Rename method, update argument and hook method into UI event
180 | public void onButtonPressed(Uri uri) {
181 | if (mListener != null) {
182 | mListener.onFragmentInteraction(uri);
183 | }
184 | }
185 |
186 | @Override
187 | public void onAttach(Context context) {
188 | super.onAttach(context);
189 | if (context instanceof OnFragmentInteractionListener) {
190 | mListener = (OnFragmentInteractionListener) context;
191 | } else {
192 | throw new RuntimeException(context.toString()
193 | + " must implement OnFragmentInteractionListener");
194 | }
195 | }
196 |
197 | @Override
198 | public void onDetach() {
199 | super.onDetach();
200 | mListener = null;
201 | }
202 |
203 | /**
204 | * This interface must be implemented by activities that contain this
205 | * fragment to allow an interaction in this fragment to be communicated
206 | * to the activity and potentially other fragments contained in that
207 | * activity.
208 | *
209 | * See the Android Training lesson Communicating with Other Fragments for more information.
212 | */
213 | public interface OnFragmentInteractionListener {
214 | // TODO: Update argument type and name
215 | void onFragmentInteraction(Uri uri);
216 | }
217 | }
218 |
--------------------------------------------------------------------------------
/app/src/main/java/com/skripsi/anna/User.java:
--------------------------------------------------------------------------------
1 | package com.skripsi.anna;
2 |
3 | import android.content.Context;
4 | import android.net.Uri;
5 | import android.os.Bundle;
6 | import android.support.design.widget.Snackbar;
7 | import android.support.v4.app.Fragment;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.Button;
12 | import android.widget.EditText;
13 |
14 | import com.android.volley.Request;
15 | import com.android.volley.RequestQueue;
16 | import com.android.volley.Response;
17 | import com.android.volley.VolleyError;
18 | import com.android.volley.toolbox.StringRequest;
19 | import com.android.volley.toolbox.Volley;
20 |
21 | import org.json.JSONArray;
22 | import org.json.JSONException;
23 | import org.json.JSONObject;
24 |
25 | import java.util.HashMap;
26 | import java.util.Map;
27 |
28 |
29 | /**
30 | * A simple {@link Fragment} subclass.
31 | * Activities that contain this fragment must implement the
32 | * {@link User.OnFragmentInteractionListener} interface
33 | * to handle interaction events.
34 | * Use the {@link User#newInstance} factory method to
35 | * create an instance of this fragment.
36 | */
37 | public class User extends Fragment {
38 | EditText Nama,Email,Hp;
39 | Button Update;
40 | SessionManager session;
41 | // TODO: Rename parameter arguments, choose names that match
42 | // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
43 | private static final String ARG_PARAM1 = "param1";
44 | private static final String ARG_PARAM2 = "param2";
45 |
46 | // TODO: Rename and change types of parameters
47 | private String mParam1;
48 | private String mParam2;
49 |
50 | private OnFragmentInteractionListener mListener;
51 |
52 | public User() {
53 | // Required empty public constructor
54 | }
55 |
56 | /**
57 | * Use this factory method to create a new instance of
58 | * this fragment using the provided parameters.
59 | *
60 | * @param param1 Parameter 1.
61 | * @param param2 Parameter 2.
62 | * @return A new instance of fragment User.
63 | */
64 | // TODO: Rename and change types and number of parameters
65 | public static User newInstance(String param1, String param2) {
66 | User fragment = new User();
67 | Bundle args = new Bundle();
68 | args.putString(ARG_PARAM1, param1);
69 | args.putString(ARG_PARAM2, param2);
70 | fragment.setArguments(args);
71 | return fragment;
72 | }
73 |
74 | @Override
75 | public void onCreate(Bundle savedInstanceState) {
76 | super.onCreate(savedInstanceState);
77 | if (getArguments() != null) {
78 | mParam1 = getArguments().getString(ARG_PARAM1);
79 | mParam2 = getArguments().getString(ARG_PARAM2);
80 | }
81 | }
82 |
83 | @Override
84 | public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
85 | final View view = inflater.inflate(R.layout.fragment_user, container, false);
86 | session = new SessionManager(view.getContext());
87 | final HashMap user = session.getUserDetails();
88 | Nama = (EditText) view.findViewById(R.id.Nama);
89 | Email = (EditText) view.findViewById(R.id.Email);
90 | Hp = (EditText) view.findViewById(R.id.Hp);
91 |
92 | StringRequest stringRequest = new StringRequest(Request.Method.GET, Constant.GetUser+user.get(SessionManager.KEY_ID), new Response.Listener() {
93 | @Override
94 | public void onResponse(String response) {
95 | try {
96 | JSONArray jsonArray = new JSONArray(response);
97 | for (int i=0;i() {
134 | @Override
135 | public void onResponse(String response) {
136 |
137 | try {
138 | JSONArray jsonArray = new JSONArray(response);
139 | for (int i=0;i getParams() {
166 | Map params = new HashMap();
167 | params.put("upd", "y");
168 | params.put("id_user",user.get(SessionManager.KEY_ID));
169 | params.put("nama_user", Nama.getText().toString());
170 | params.put("email_user", Email.getText().toString());
171 | params.put("hp_user", Hp.getText().toString());
172 | return params;
173 | }
174 | };
175 | RequestQueue requestQueue = Volley.newRequestQueue(view.getContext());
176 | requestQueue.add(stringRequest);
177 | }
178 | });
179 | return view;
180 | }
181 |
182 | // TODO: Rename method, update argument and hook method into UI event
183 | public void onButtonPressed(Uri uri) {
184 | if (mListener != null) {
185 | mListener.onFragmentInteraction(uri);
186 | }
187 | }
188 |
189 | @Override
190 | public void onAttach(Context context) {
191 | super.onAttach(context);
192 | if (context instanceof OnFragmentInteractionListener) {
193 | mListener = (OnFragmentInteractionListener) context;
194 | } else {
195 | throw new RuntimeException(context.toString()
196 | + " must implement OnFragmentInteractionListener");
197 | }
198 | }
199 |
200 | @Override
201 | public void onDetach() {
202 | super.onDetach();
203 | mListener = null;
204 | }
205 |
206 | /**
207 | * This interface must be implemented by activities that contain this
208 | * fragment to allow an interaction in this fragment to be communicated
209 | * to the activity and potentially other fragments contained in that
210 | * activity.
211 | *
212 | * See the Android Training lesson Communicating with Other Fragments for more information.
215 | */
216 | public interface OnFragmentInteractionListener {
217 | // TODO: Update argument type and name
218 | void onFragmentInteraction(Uri uri);
219 | }
220 | }
221 |
--------------------------------------------------------------------------------