From 62f7746d4e7025840f2283592b27e3fccd666d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yi=C4=9Fit=20=C3=87olako=C4=9Flu?= Date: Mon, 20 May 2019 13:35:32 +0300 Subject: [PATCH] changes --- .../java/gq/yigit/mycity/MainFragment.java | 22 ++++++-- .../mycity/votesFragment/VotesFragment.java | 18 +++++- .../app/src/main/res/layout/fragment_main.xml | 11 +++- .../main/res/layout/fragment_votes_list.xml | 39 +++++++------ .../__pycache__/navigation.cpython-37.pyc | Bin 9912 -> 9911 bytes .../__pycache__/smart_park.cpython-37.pyc | Bin 4156 -> 4155 bytes traffic_analyzer/ambulance_detect.py | 53 +++++++++++++----- 7 files changed, 103 insertions(+), 40 deletions(-) diff --git a/MyCity/app/src/main/java/gq/yigit/mycity/MainFragment.java b/MyCity/app/src/main/java/gq/yigit/mycity/MainFragment.java index 27819ce..b8dd28c 100644 --- a/MyCity/app/src/main/java/gq/yigit/mycity/MainFragment.java +++ b/MyCity/app/src/main/java/gq/yigit/mycity/MainFragment.java @@ -7,6 +7,7 @@ import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.support.v4.widget.SwipeRefreshLayout; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -37,6 +38,7 @@ public class MainFragment extends Fragment implements WebRequest.responseListene private TextView pres_text; private ImageView weather_img; private RecyclerView recyclerView; + private SwipeRefreshLayout swipeRefreshLayout; private String key = "d6907927a2b9224a0b60d0565c207377"; private String url; @@ -65,6 +67,7 @@ public class MainFragment extends Fragment implements WebRequest.responseListene pres_text = rootView.findViewById(R.id.pressure); weather_img = rootView.findViewById(R.id.forecast_img); recyclerView = rootView.findViewById(R.id.anouncements); + swipeRefreshLayout = rootView.findViewById(R.id.simpleSwipeRefreshLayout); HashMap params = new HashMap<>(); params.put("q","Ankara,tr"); @@ -76,10 +79,22 @@ public class MainFragment extends Fragment implements WebRequest.responseListene WebRequest request = new WebRequest("https://api.openweathermap.org/data/2.5/weather",true,params,0); request.addListener(this); request.execute(); - + swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + swipeRefreshLayout.setRefreshing(false); + refresh(); + } + }); return rootView; } + public void refresh() { + WebRequest request = new WebRequest(url + "/announcements",true,new HashMap(),1); + request.addListener(this); + request.execute(); + } + public void onButtonPressed(Uri uri) { if (mListener != null) { mListener.onFragmentInteraction(uri); @@ -151,10 +166,7 @@ public class MainFragment extends Fragment implements WebRequest.responseListene @Override public void imageDownloaded(Bitmap img) { weather_img.setImageBitmap(Bitmap.createScaledBitmap(img,100,100,true)); - - WebRequest request = new WebRequest(url + "/announcements",true,new HashMap(),1); - request.addListener(this); - request.execute(); + refresh(); } public interface OnRecyclerViewInteractionListener { diff --git a/MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/VotesFragment.java b/MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/VotesFragment.java index bb3d086..f6813d7 100644 --- a/MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/VotesFragment.java +++ b/MyCity/app/src/main/java/gq/yigit/mycity/votesFragment/VotesFragment.java @@ -4,6 +4,7 @@ import android.content.Context; import android.graphics.Bitmap; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; @@ -30,6 +31,7 @@ public class VotesFragment extends Fragment implements responseListener, imageLi private int mColumnCount = 1; private OnListFragmentInteractionListener mListener; public RecyclerView recyclerView; + public SwipeRefreshLayout swipeRefreshLayout; public String url; public int img_count = 0; public JSONArray votes; @@ -59,7 +61,7 @@ public class VotesFragment extends Fragment implements responseListener, imageLi public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_votes_list, container, false); - + // swipeRefreshLayout = view.findViewById(R.id.simpleSwipeRefreshLayout); // Set the adapter if (view instanceof RecyclerView) { Context context = view.getContext(); @@ -75,10 +77,22 @@ public class VotesFragment extends Fragment implements responseListener, imageLi web_manager.addListener(this); web_manager.execute(); } + /* swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + swipeRefreshLayout.setRefreshing(false); + refresh(); + } + }); + */ return view; } - + public void refresh() { + WebRequest web_manager = new WebRequest(url + "/votings/",true,new HashMap(),0); + web_manager.addListener(this); + web_manager.execute(); + } @Override public void onAttach(Context context) { super.onAttach(context); diff --git a/MyCity/app/src/main/res/layout/fragment_main.xml b/MyCity/app/src/main/res/layout/fragment_main.xml index c55705d..fcf0605 100644 --- a/MyCity/app/src/main/res/layout/fragment_main.xml +++ b/MyCity/app/src/main/res/layout/fragment_main.xml @@ -52,7 +52,12 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/announcement_title" android:textSize="24sp" android:textColor="#000000" android:layout_marginBottom="15dp" android:layout_marginLeft="7dp"/> - + + + \ No newline at end of file diff --git a/MyCity/app/src/main/res/layout/fragment_votes_list.xml b/MyCity/app/src/main/res/layout/fragment_votes_list.xml index fe5a0d3..bc3c84c 100644 --- a/MyCity/app/src/main/res/layout/fragment_votes_list.xml +++ b/MyCity/app/src/main/res/layout/fragment_votes_list.xml @@ -1,18 +1,23 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/server_side/api/modules/__pycache__/navigation.cpython-37.pyc b/server_side/api/modules/__pycache__/navigation.cpython-37.pyc index a1d2bf330f7e3e9b0418b746e6d7da89e4c375dd..4ffa002e42e19d39b67caeb4ef61e53aeebdb972 100644 GIT binary patch delta 111 zcmdntyWN-1iIw)b|niU}=FEh>%)NlnSi&rZ!NF))mA$uG~# z$xlovj`6K@&Mc{n0jelVEs8JBOi7JNEXa(>%}*)KNiB}qoWrav&vPITJJ2a3h}_vxAR*Mt*Lper0BQW=g((K~a8IYH~@jesFGL zQAxaSVqRi;YHn&?iGFcvQCVtHd~s$x8iI$mIL{ Fu>gsDGR*)0 delta 182 zcmdn3ut$N z(MA4~OL(0beJAhW4FC#r@*QK0n|y&!pD}b2e-C5)HTP%qcnZ>tQ@(WV) bZZW3aV$I1B7!I1L", size) + data) + except: + conn_switch = False + cv2.imshow("Cam",image) + cv2.imshow("Cut",image_np) t2 = time.time() print("time taken for {}".format(t2-t1))