diff --git a/app/app.iml b/app/app.iml index ef91577..bbb0a83 100644 --- a/app/app.iml +++ b/app/app.iml @@ -117,45 +117,32 @@ - + + - - + - - - - + - + - - - - - - + + - - - - - + + - - - + - - + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 72de3f3..b5b5ec7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,11 +8,12 @@ android { targetSdkVersion 26 versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + resConfigs "en", "es", "ja", "in" } buildTypes { release { - minifyEnabled false + minifyEnabled true + shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } @@ -22,15 +23,12 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support:design:26.1.0' - implementation 'com.android.support.constraint:constraint-layout:1.0.2' implementation 'com.android.support:support-v4:26.1.0' - implementation 'com.google.android.gms:play-services-maps:11.8.0' - implementation 'com.google.android.gms:play-services-location:11.8.0' - testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.1' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' + implementation 'com.google.android.gms:play-services-maps:12.0.1' + implementation 'com.google.android.gms:play-services-location:12.0.1' compile 'com.jakewharton:butterknife:8.8.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' - compile 'com.android.support:recyclerview-v7:25.3.1' + compile 'com.android.support:recyclerview-v7:26.1.0' + compile 'com.android.support:cardview-v7:26.1.0' compile 'com.google.code.gson:gson:2.8.0' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d56bba2..6380255 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,29 +1,43 @@ - + + + + + + android:supportsRtl="true"> + android:label="@string/app_name" + android:screenOrientation="portrait" + android:theme="@style/AppNoBarTheme"> - + + + + + + - - \ No newline at end of file diff --git a/app/src/main/java/com/limefriends/molde/MoldeMainActivity.java b/app/src/main/java/com/limefriends/molde/MoldeMainActivity.java index 3643b08..3e96b3e 100644 --- a/app/src/main/java/com/limefriends/molde/MoldeMainActivity.java +++ b/app/src/main/java/com/limefriends/molde/MoldeMainActivity.java @@ -1,14 +1,20 @@ package com.limefriends.molde; -import android.support.v4.app.Fragment; +import android.content.Context; +import android.content.Intent; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; +import android.widget.Toast; import com.limefriends.molde.menu_magazine.MoldeMagazineFragment; +import com.limefriends.molde.menu_map.entity.MoldeSearchMapHistoryEntity; +import com.limefriends.molde.menu_map.entity.MoldeSearchMapInfoEntity; import com.limefriends.molde.menu_map.MoldeMapFragment; import com.limefriends.molde.menu_mypage.MoldeMyPageFragment; import com.limefriends.molde.menu_reportlist.MoldeReportListFragment; @@ -17,16 +23,24 @@ import butterknife.ButterKnife; public class MoldeMainActivity extends AppCompatActivity { - @BindView(R.id.navigation) BottomNavigationView navigation; - FragmentTransaction ft; + public static Context allContext; + @BindView(R.id.navigation) + BottomNavigationView navigation; + private long lastTimeBackPressed; + private FragmentTransaction ft; + private FragmentManager fm; + private MoldeSearchMapInfoEntity entity; + private MoldeSearchMapHistoryEntity historyEntity; + private Fragment fragment; private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.main_menu_map: - replaceFragment(MoldeMapFragment.newInstance()); + fragment = MoldeMapFragment.newInstance(); + replaceFragment(fragment); return true; case R.id.main_menu_magazine: replaceFragment(MoldeMagazineFragment.newInstance()); @@ -42,16 +56,30 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) { } }; + onKeyBackPressedListener mOnKeyBackPressedListener; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_molde_main); ButterKnife.bind(this); + + fragment = MoldeMapFragment.newInstance(); BottomNavigationViewHelper.disableShiftMode(navigation); navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); - ft = getSupportFragmentManager().beginTransaction(); - ft.add(R.id.menu_fragment, MoldeMapFragment.newInstance()).commit(); + fm = getSupportFragmentManager(); + ft = fm.beginTransaction(); + ft.add(R.id.menu_fragment, fragment).commit(); + allContext = this; + } + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + if (fragment != null && fragment instanceof MoldeMapFragment) { + ((MoldeMapFragment) fragment).onPermissionCheck(requestCode, permissions, grantResults); + } + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + + } private void replaceFragment(Fragment fm) { @@ -59,4 +87,43 @@ private void replaceFragment(Fragment fm) { ft.replace(R.id.menu_fragment, fm).commit(); } + @Override + protected void onResume() { + super.onResume(); + Intent intent = getIntent(); + entity = (MoldeSearchMapInfoEntity) intent.getSerializableExtra("mapInfo"); + historyEntity = (MoldeSearchMapHistoryEntity) intent.getSerializableExtra("mapHistoryInfo"); + + } + + public MoldeSearchMapInfoEntity getMapInfoResultData() { + return this.entity; + } + + public MoldeSearchMapHistoryEntity getMapHistoryResultData() { + return this.historyEntity; + } + + public interface onKeyBackPressedListener { + void onBackKey(); + } + + public void setOnKeyBackPressedListener(onKeyBackPressedListener listener) { + mOnKeyBackPressedListener = listener; + } + + @Override + public void onBackPressed() { + if (System.currentTimeMillis() > lastTimeBackPressed + 1500) { + lastTimeBackPressed = System.currentTimeMillis(); + Toast.makeText(getApplicationContext(), "한번 더 누르면 종료", Toast.LENGTH_SHORT); + if (mOnKeyBackPressedListener != null) { + mOnKeyBackPressedListener.onBackKey(); + return; + } + return; + } else { + finish(); + } + } } diff --git a/app/src/main/java/com/limefriends/molde/menu_magazine/MoldeMagazineFragment.java b/app/src/main/java/com/limefriends/molde/menu_magazine/MoldeMagazineFragment.java index 623db53..a3291c3 100644 --- a/app/src/main/java/com/limefriends/molde/menu_magazine/MoldeMagazineFragment.java +++ b/app/src/main/java/com/limefriends/molde/menu_magazine/MoldeMagazineFragment.java @@ -1,14 +1,16 @@ package com.limefriends.molde.menu_magazine; +import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import com.limefriends.molde.MoldeMainActivity; import com.limefriends.molde.R; -public class MoldeMagazineFragment extends Fragment { +public class MoldeMagazineFragment extends Fragment implements MoldeMainActivity.onKeyBackPressedListener{ public static MoldeMagazineFragment newInstance() { return new MoldeMagazineFragment(); @@ -17,9 +19,16 @@ public static MoldeMagazineFragment newInstance() { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - - return inflater.inflate(R.layout.fragment_molde_magazine, container, false); + return inflater.inflate(R.layout.magazine_fragment, container, false); } + @Override + public void onAttach(Context context) { + super.onAttach(context); + ((MoldeMainActivity)context).setOnKeyBackPressedListener(this); + } + @Override + public void onBackKey() { + } } diff --git a/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapFragment.java b/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapFragment.java index 826a045..88623ec 100644 --- a/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapFragment.java +++ b/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapFragment.java @@ -1,15 +1,34 @@ package com.limefriends.molde.menu_map; +import android.Manifest; +import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.Drawable; +import android.location.Location; +import android.location.LocationListener; +import android.location.LocationManager; import android.os.Bundle; -import android.support.design.widget.TextInputEditText; -import android.support.design.widget.TextInputLayout; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v4.app.ActivityCompat; import android.support.v4.app.Fragment; +import android.support.v4.view.ViewPager; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.widget.Button; +import android.widget.FrameLayout; +import android.widget.ImageButton; import android.widget.LinearLayout; +import android.widget.ProgressBar; import android.widget.RelativeLayout; +import android.widget.TextView; import android.widget.Toast; import com.google.android.gms.maps.CameraUpdateFactory; @@ -19,31 +38,113 @@ import com.google.android.gms.maps.UiSettings; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.android.gms.maps.model.LatLng; +import com.google.android.gms.maps.model.Marker; import com.google.android.gms.maps.model.MarkerOptions; + import com.limefriends.molde.R; +import com.limefriends.molde.MoldeMainActivity; +import com.limefriends.molde.menu_map.entity.MoldeSearchMapHistoryEntity; +import com.limefriends.molde.menu_map.entity.MoldeSearchMapInfoEntity; +import com.limefriends.molde.menu_map.reportCard.*; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.StringTokenizer; import butterknife.BindView; import butterknife.ButterKnife; -public class MoldeMapFragment extends Fragment implements OnMapReadyCallback { - private GoogleMap mMap; - private String lat; - private String lng; - @BindView(R.id.map_ui) RelativeLayout map_ui; - @BindView(R.id.loc_search_bar) LinearLayout search_bar; +public class MoldeMapFragment extends Fragment + implements OnMapReadyCallback, + MoldeMainActivity.onKeyBackPressedListener, + MoldeMapReportPagerAdapterCallback { + //맵 구성 + @BindView(R.id.map_ui) + RelativeLayout map_ui; + @BindView(R.id.map_view_layout) + LinearLayout map_view_layout; + + @BindView(R.id.loc_search_bar) + LinearLayout search_bar; + @BindView(R.id.loc_search_input) + TextView loc_search_input; + + //하단에 구성한 옵션 + @BindView(R.id.map_option_layout) + RelativeLayout map_option_layout; + @BindView(R.id.my_loc_button) + ImageButton my_loc_button; + @BindView(R.id.favorite_button) + ImageButton favorite_button; + @BindView(R.id.report_button) + ImageButton report_button; + + //만약 로딩 중이거나 권한이 없을 때 + @BindView(R.id.map_view_progress) + RelativeLayout map_view_progress; + @BindView(R.id.progress_loading) + ProgressBar progress_loading; + @BindView(R.id.request_gps_button) + Button request_gps_button; + + //신고 리스트 보여주는 리스트 + @BindView(R.id.report_card_layout) + FrameLayout report_card_layout; + @BindView(R.id.report_card_view) + ViewPager report_card_view_pager; + + SupportMapFragment mapView; + private static GoogleMap mMap; + private String lat = "37.499597"; + private String lng = "127.031372"; + private String searchName = ""; + private String telNo = ""; + private int moveCnt = 0; + private int animateUpCnt = 0; + private boolean backChk = false; + private boolean initChk = false; + private boolean myLocChange = false; + private LocationManager manager; + private MyLocationListener myLocationListener; + private boolean gpsEnable = false; + private long gpsRequestTime = 0; + private Marker myMarker; + private ArrayList reportInfohMarkers; + private final int REQUEST_LOCATION = 1; + private ArrayList reportCardItemList; + private ReportCardPagerAdapter reportCardAdapter; + private ShadowTransformer reportCardShadowTransformer; + + public ArrayList beforeCallApplyMethodTimeList; + private ArrayList reportCardPositionList; + private boolean firstPresentReportCard = false; public static MoldeMapFragment newInstance() { return new MoldeMapFragment(); } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_molde_map, container, false); + public View onCreateView(LayoutInflater inflater, + @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.map_fragment, container, false); ButterKnife.bind(this, view); - SupportMapFragment mapView = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.mapView); + mapView = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.mapView); mapView.getMapAsync(this); + if (moveCnt == 0) { + getMyLocation(); + } + + //뷰페이저어댑터 생성 및 콜백 지정 + reportInfohMarkers = new ArrayList(); + reportCardItemList = new ArrayList(); + reportCardAdapter = new ReportCardPagerAdapter(getContext()); + reportCardAdapter.setCallback(this); + search_bar.setElevation(12); search_bar.setOnClickListener(new View.OnClickListener() { @Override @@ -51,62 +152,500 @@ public void onClick(View view) { Toast.makeText(getContext(), "검색 창으로 이동", Toast.LENGTH_LONG).show(); Intent intent = new Intent(); intent.setClass(getContext(), MoldeSearchMapInfoActivity.class); + intent.putExtra("searchName", searchName); startActivity(intent); } }); map_ui.bringToFront(); + report_card_layout.setVisibility(View.INVISIBLE); + + my_loc_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Toast.makeText(getContext(), "위치 가져오기 기능", Toast.LENGTH_LONG).show(); + loc_search_input.setText(R.string.search); + searchName = "검색하기"; + myLocChange = true; + getMyLocation(); + } + }); + favorite_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Toast.makeText(getContext(), "즐겨찾기 페이지로 넘어가기", Toast.LENGTH_LONG).show(); + } + }); + report_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Toast.makeText(getContext(), "신고 페이지로 넘어가기", Toast.LENGTH_LONG).show(); + Intent intent = new Intent(); + intent.setClass(getContext(), MoldeReportActivity.class); + startActivity(intent); + } + }); + + request_gps_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED + && ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(getActivity(), + new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION, + android.Manifest.permission.ACCESS_FINE_LOCATION}, + REQUEST_LOCATION); + return; + } + } + }); + + initChk = true; return view; } + @Override + public void onStart() { + super.onStart(); + } @Override - public void onMapReady(GoogleMap googleMap) { - mMap = googleMap; - lat = "37.3928948"; - lng = "126.72539759999995"; + public void onResume() { + super.onResume(); + report_card_layout.setVisibility(View.INVISIBLE); + if (getActivity() != null && getActivity() instanceof MoldeMainActivity) { + MoldeSearchMapInfoEntity entity = ((MoldeMainActivity) getActivity()).getMapInfoResultData(); + MoldeSearchMapHistoryEntity historyEntity = ((MoldeMainActivity) getActivity()).getMapHistoryResultData(); + if (entity != null) { + map_view_progress.setVisibility(View.INVISIBLE); + //Toast.makeText(getContext(), entity.toString(), Toast.LENGTH_LONG).show(); + lat = entity.getMapLat(); + lng = entity.getMapLng(); + searchName = entity.getName(); + telNo = entity.getTelNo(); + loc_search_input.setText(searchName); + report_card_layout.bringToFront(); + report_card_layout.setVisibility(View.VISIBLE); + map_option_layout.setVisibility(View.INVISIBLE); + initChk = false; + if (MoldeSearchMapInfoActivity.checkBackPressed == false && backChk == false) { + //이곳에 좌표를 기준으로 검색 메서드를 추가해야함 + moveCnt++; + } + } else if (entity == null && historyEntity != null) { + map_view_progress.setVisibility(View.INVISIBLE); + //Toast.makeText(getContext(), historyEntity.toString(), Toast.LENGTH_LONG).show(); + lat = historyEntity.getMapLat(); + lng = historyEntity.getMapLng(); + searchName = historyEntity.getName(); + telNo = historyEntity.getTelNo(); + loc_search_input.setText(searchName); + report_card_layout.bringToFront(); + report_card_layout.setVisibility(View.VISIBLE); + map_option_layout.setVisibility(View.INVISIBLE); + initChk = false; + if (MoldeSearchMapInfoActivity.checkBackPressed == false && backChk == false) { + //이곳에 좌표를 기준으로 검색 메서드를 추가해야함 - //초기 좌표 설정 - LatLng initialLatLng = new LatLng(Double.parseDouble(lat), Double.parseDouble(lng)); + moveCnt++; + } - /* - 지도를 마커위치로 이동해야함 - */ - mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(initialLatLng, 17)); - /* - 지도 UI 설정 ZOOM 레벨 설정 - */ + } + } + } - mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); + @Override + public void onPause() { + super.onPause(); + } - UiSettings uiSettings = mMap.getUiSettings(); - uiSettings.setZoomControlsEnabled(false); - uiSettings.setCompassEnabled(true); - uiSettings.setMapToolbarEnabled(true); - uiSettings.setMyLocationButtonEnabled(true); + @Override + public void onAttach(Context context) { + super.onAttach(context); + ((MoldeMainActivity) context).setOnKeyBackPressedListener(this); + if (report_card_layout != null) { + Animation trans_to_down = AnimationUtils.loadAnimation(getContext(), R.anim.trans_to_down); + report_card_layout.startAnimation(trans_to_down); + report_card_layout.setVisibility(View.INVISIBLE); + } + } + + @Override + public void onMapReady(GoogleMap googleMap) { + mMap = googleMap; + + LatLng moveLoc = new LatLng(Double.parseDouble(lat), Double.parseDouble(lng)); + mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(moveLoc, 17)); + + if (searchName.equals("")) { + mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); + UiSettings uiSettings = mMap.getUiSettings(); + uiSettings.setZoomControlsEnabled(false); + uiSettings.setCompassEnabled(true); + uiSettings.setMapToolbarEnabled(true); + uiSettings.setMyLocationButtonEnabled(true); + } else if (!searchName.equals("")) { + if (searchName.charAt(searchName.length() - 1) == '동') { + StringTokenizer placeInfo = new StringTokenizer(searchName, " "); + String si = placeInfo.nextToken(); + String gu = placeInfo.nextToken(); + String dong = placeInfo.nextToken(); + if (gu.charAt(gu.length() - 1) == '구' && dong.charAt(dong.length() - 1) == '동') { + //주변 위치에 따라 검색해오기 + Toast.makeText(getContext(), "시 구 동에 따라 안에 있는 정보들 보여주기", Toast.LENGTH_LONG).show(); + /*Animation trans_to_down = AnimationUtils.loadAnimation(getContext(), R.anim.trans_to_down); + report_card_layout.startAnimation(trans_to_down); + report_card_layout.setVisibility(View.GONE); + report_card_layout.setClickable(false); + map_option_layout.setVisibility(View.VISIBLE); + backChk = true;*/ + makeSearchMarkers(moveLoc); + } + } else { + makeSearchMarker(); + } + } - MarkerOptions markerOptions = new MarkerOptions(); - LatLng myLocation = new LatLng(Double.parseDouble(lat), Double.parseDouble(lng)); - markerOptions.position(myLocation); - markerOptions.title("제목"); - markerOptions.snippet("내용"); - markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_icon)); - mMap.addMarker(markerOptions).showInfoWindow(); /*********************** Map Click ***********************/ mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() { @Override public void onMapClick(LatLng latLng) { - + if (View.VISIBLE == report_card_layout.getVisibility()) { + Animation trans_to_down = AnimationUtils.loadAnimation(getContext(), R.anim.trans_to_down); + report_card_layout.startAnimation(trans_to_down); + report_card_layout.setVisibility(View.GONE); + report_card_layout.setClickable(false); + map_option_layout.setVisibility(View.VISIBLE); + backChk = true; + } } }); /*********************** Map long Click ***********************/ mMap.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() { @Override public void onMapLongClick(LatLng latLng) { + makeNewMarker(latLng); + } + }); + + /*********************** Map detect Deselect Marker ***********************/ + mMap.setOnInfoWindowCloseListener(new GoogleMap.OnInfoWindowCloseListener() { + @Override + public void onInfoWindowClose(Marker marker) { + if (marker.getTitle().equals("내 위치") || marker.getTitle().equals("이름 없음")) { + marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.my_location_icon)); + } else { + marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.map_icon)); + } + } + }); + + mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { + + @Override + public boolean onMarkerClick(Marker marker) { + if (moveCnt > 0 && backChk == true) { + report_card_layout.setVisibility(View.VISIBLE); + map_option_layout.setVisibility(View.INVISIBLE); + Animation trans_to_up = AnimationUtils.loadAnimation(getContext(), R.anim.trans_to_up); + report_card_layout.startAnimation(trans_to_up); + report_card_layout.bringToFront(); + backChk = false; + } + + if (marker.getTitle().equals("내 위치")) { + marker.setIcon(BitmapDescriptorFactory.fromBitmap(resizeMapIcon(R.drawable.my_location_icon))); + if (report_card_layout.getVisibility() == View.VISIBLE) { + Animation trans_to_down = AnimationUtils.loadAnimation(getContext(), R.anim.trans_to_down); + report_card_layout.startAnimation(trans_to_down); + report_card_layout.setVisibility(View.GONE); + report_card_layout.setClickable(false); + map_option_layout.setVisibility(View.VISIBLE); + backChk = true; + } + return false; + } + if (marker.getTitle().equals("이름 없음")) { + marker.setIcon(BitmapDescriptorFactory.fromBitmap(resizeMapIcon(R.drawable.my_loc_button))); + if (report_card_layout.getVisibility() == View.VISIBLE) { + Animation trans_to_down = AnimationUtils.loadAnimation(getContext(), R.anim.trans_to_down); + report_card_layout.startAnimation(trans_to_down); + report_card_layout.setVisibility(View.GONE); + report_card_layout.setClickable(false); + map_option_layout.setVisibility(View.VISIBLE); + backChk = true; + Toast.makeText(getContext(), "정보 추가하는 창 띄우기", Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(getContext(), "정보 추가하는 창 띄우기", Toast.LENGTH_SHORT).show(); + } + return false; + } + + if (reportInfohMarkers != null) { + for (int i = 0; i < reportInfohMarkers.size(); i++) { + if (marker.getTitle().equals(reportInfohMarkers.get(i).getTitle())) { + marker.setIcon(BitmapDescriptorFactory.fromBitmap(resizeMapIcon(R.drawable.map_icon))); + report_card_view_pager.setCurrentItem(i, false); + return false; + } + } + } + return false; } }); } + + private Bitmap resizeMapIcon(int imageId) { + int resizeWidth = 120; + Bitmap original = BitmapFactory.decodeResource(getResources(), imageId); + double aspectRatio = (double) original.getHeight() / (double) original.getWidth(); + int targetHeight = (int) (resizeWidth * aspectRatio); + Bitmap result = Bitmap.createScaledBitmap(original, resizeWidth, targetHeight, false); + if (result != original) { + original.recycle(); + } + return result; + } + + //GPS 권한체크 및 얻기 + public void onPermissionCheck(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + if (requestCode == REQUEST_LOCATION) { + for (int grantResult : grantResults) { + if (grantResult == PackageManager.PERMISSION_DENIED) { + progress_loading.setVisibility(View.INVISIBLE); + request_gps_button.setVisibility(View.VISIBLE); + return; + } + } + getMyLocation(); + } else { + getMyLocation(); + } + } + + public void getMyLocation() { + manager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE); + gpsEnable = false; + if (manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { + gpsEnable = true; + } + if (gpsEnable) { + final long minTime = 3000; + final float minDistance = 100; + if (myLocationListener == null) { + myLocationListener = new MyLocationListener(); + if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED + && ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(getActivity(), + new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION, + android.Manifest.permission.ACCESS_FINE_LOCATION}, + REQUEST_LOCATION); + return; + } + } + manager.requestLocationUpdates(LocationManager.GPS_PROVIDER, minTime, minDistance, myLocationListener); + manager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, minTime, minDistance, myLocationListener); + gpsRequestTime = System.currentTimeMillis(); + } else { + Toast.makeText(getContext(), "GPS를 사용할 수 있도록 켜주셔야 사용이 가능합니다.", Toast.LENGTH_LONG).show(); + map_view_progress.setVisibility(View.INVISIBLE); + } + } + + public class MyLocationListener implements LocationListener { + //위치정보 보여주기 + //구글 맵 이동 + int locChangeCount = 0; + + @Override + public void onLocationChanged(Location location) { + if (searchName.equals("") || myLocChange == true) { + /*if(System.currentTimeMillis() - gpsRequestTime > 3000){ + Toast.makeText(getContext(), "건물 안에서는 더 오랜 시간이 걸립니다", Toast.LENGTH_SHORT).show(); + }*/ + if (locChangeCount == 0) { + double latitude = location.getLatitude(); + double longitude = location.getLongitude(); + LatLng myLocation = new LatLng(latitude, longitude); + mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(myLocation, 17)); + if (myMarker != null) { + myMarker.remove(); + } + myMarker = mMap.addMarker( + new MarkerOptions() + .position(myLocation) + .title("내 위치") + //.snippet("내 정보") + .icon(BitmapDescriptorFactory.fromResource(R.drawable.my_location_icon) + ) + ); + locChangeCount++; + myLocChange = false; + if (moveCnt > 0) { + if (reportInfohMarkers.size() > 0 || reportCardItemList.size() > 0) { + for (Marker marker : reportInfohMarkers) { + marker.remove(); + } + reportInfohMarkers.clear(); + reportCardItemList.clear(); + reportCardAdapter.removeAllCardItem(); + report_card_view_pager.setAdapter(reportCardAdapter); + } + beforeCallApplyMethodTimeList = new ArrayList(); + reportCardPositionList = new ArrayList(); + makeRandomMarkers(myLocation); + + report_card_layout.setVisibility(View.VISIBLE); + map_option_layout.setVisibility(View.INVISIBLE); + Animation trans_to_up = AnimationUtils.loadAnimation(getContext(), R.anim.trans_to_up); + report_card_layout.startAnimation(trans_to_up); + report_card_layout.bringToFront(); + report_card_layout.setClickable(true); + backChk = false; + initChk = false; + + /*Animation trans_to_down = AnimationUtils.loadAnimation(getContext(), R.anim.trans_to_down); + report_card_layout.startAnimation(trans_to_down); + report_card_layout.setVisibility(View.GONE); + report_card_layout.setClickable(false); + map_option_layout.setVisibility(View.VISIBLE); + backChk = true; + initChk = true; + myMarker.showInfoWindow(); + myMarker.setIcon(BitmapDescriptorFactory.fromBitmap(resizeMapIcon(R.drawable.my_location_icon))); + mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(myLocation, 15));*/ + } + moveCnt++; + } + } + if(manager != null && myLocationListener != null){ + manager.removeUpdates(myLocationListener); + myLocationListener = null; + map_view_progress.setVisibility(View.INVISIBLE); + } + } + + @Override + public void onStatusChanged(String provider, int status, Bundle bundle) { + } + + @Override + public void onProviderEnabled(String provider) { + } + + @Override + public void onProviderDisabled(String provider) { + } + + } + + //빈 정보의 마커 생성 및 후에 정보 추가 및 즐겨찾기 + public void makeNewMarker(LatLng latLng) { + MarkerOptions markerOptions = new MarkerOptions(); + markerOptions.position(latLng); + markerOptions.title("이름 없음"); + //markerOptions.snippet("정보 없음"); + markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.my_location_icon)); + Marker newMarker = mMap.addMarker(markerOptions); + } + + //검색 후 하나의 마커 생성 및 검색정보 대입 + public void makeSearchMarker() { + MarkerOptions markerOptions = new MarkerOptions(); + LatLng myLocation = new LatLng(Double.parseDouble(lat), Double.parseDouble(lng)); + markerOptions.position(myLocation); + markerOptions.title(searchName); + //markerOptions.snippet(telNo); + markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_icon)); + Marker newMarker = mMap.addMarker(markerOptions); + newMarker.showInfoWindow(); + } + + //검색 후 주변의 여러 신고장소 정보 신고 카드뷰에 추가 및 마커 추가 + public void makeSearchMarkers(LatLng moveLoc) { + beforeCallApplyMethodTimeList = new ArrayList(); + reportCardPositionList = new ArrayList(); + makeRandomMarkers(moveLoc); + } + + @Override + public void applyReportCardInfo(int position) { + if (reportInfohMarkers != null) { + if (initChk == false && backChk == false) { + if (firstPresentReportCard == true) { + if (position == 1) { + Marker marker = reportInfohMarkers.get(0); + mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(marker.getPosition(), 15)); + marker.showInfoWindow(); + firstPresentReportCard = false; + return; + } + } + } + + beforeCallApplyMethodTimeList.add(System.currentTimeMillis()); + reportCardPositionList.add(position); + if (beforeCallApplyMethodTimeList.size() == 2) { + if (beforeCallApplyMethodTimeList.get(1) - beforeCallApplyMethodTimeList.get(0) < 0.05) { + beforeCallApplyMethodTimeList.remove(1); + return; + } else { + int currPosition = reportCardPositionList.get(0); + Marker marker = reportInfohMarkers.get(currPosition); + marker.setIcon(BitmapDescriptorFactory.fromBitmap(resizeMapIcon(R.drawable.map_icon))); + Log.e("p", currPosition + ""); + mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(marker.getPosition(), 15)); + marker.showInfoWindow(); + beforeCallApplyMethodTimeList.clear(); + reportCardPositionList.clear(); + } + } + + } + } + + //랜덤으로 마커 정보 10개 추가 및 카드뷰 추가 - 테스트용 + public void makeRandomMarkers(LatLng moveLoc) { + double start = -0.000000001; + double end = 0.000000001; + double rng = (end - start) + 0.01; + Random randomGenerator = new Random(); + for (int i = 0; i < 10; i++) { + double rndValLat = (randomGenerator.nextDouble() * rng) + start; + double rndValLng = (randomGenerator.nextDouble() * rng) + start; + LatLng latLng = new LatLng(moveLoc.latitude + rndValLat, moveLoc.longitude + rndValLng); + + Marker currMarker = mMap.addMarker(new MarkerOptions() + .position(latLng) + .title(i + 1 + "번째") + //.snippet(latLng.latitude + ", " + latLng.longitude) + .icon(BitmapDescriptorFactory.fromResource(R.drawable.map_icon)) + ); + reportInfohMarkers.add(currMarker); + reportCardItemList.add(new ReportCardItem(currMarker.getTitle(), currMarker.getSnippet())); + reportCardAdapter.addCardItem(new ReportCardItem(currMarker.getTitle(), currMarker.getSnippet())); + } + reportCardShadowTransformer = new ShadowTransformer(report_card_view_pager, reportCardAdapter); + report_card_view_pager.setAdapter(reportCardAdapter); + firstPresentReportCard = true; + report_card_view_pager.setPageTransformer(false, reportCardShadowTransformer); + report_card_view_pager.setOffscreenPageLimit(reportCardItemList.size()); + reportCardShadowTransformer.enableScaling(true); + } + + @Override + public void onBackKey() { + if (backChk == false && initChk == false) { + Animation trans_to_down = AnimationUtils.loadAnimation(getContext(), R.anim.trans_to_down); + report_card_layout.startAnimation(trans_to_down); + report_card_layout.setVisibility(View.GONE); + report_card_layout.setClickable(false); + map_option_layout.setVisibility(View.VISIBLE); + backChk = true; + } + } + } diff --git a/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapHistoryRecyclerViewAdapterCallback.java b/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapHistoryRecyclerViewAdapterCallback.java new file mode 100755 index 0000000..2df2f31 --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapHistoryRecyclerViewAdapterCallback.java @@ -0,0 +1,7 @@ +package com.limefriends.molde.menu_map; + +import com.limefriends.molde.menu_map.entity.MoldeSearchMapHistoryEntity; + +public interface MoldeMapHistoryRecyclerViewAdapterCallback { + void applyHistoryMapInfo(MoldeSearchMapHistoryEntity historyEntity); +} diff --git a/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapHistroyRecyclerViewAdapter.java b/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapHistroyRecyclerViewAdapter.java new file mode 100755 index 0000000..7e4c199 --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapHistroyRecyclerViewAdapter.java @@ -0,0 +1,143 @@ +package com.limefriends.molde.menu_map; + +import android.content.Context; +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.ImageButton; +import android.widget.TextView; + +import com.limefriends.molde.R; +import com.limefriends.molde.menu_map.cacheManager.Cache; +import com.limefriends.molde.menu_map.entity.MoldeSearchMapHistoryEntity; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; + +import butterknife.BindView; +import butterknife.ButterKnife; + + +public class MoldeMapHistroyRecyclerViewAdapter extends RecyclerView.Adapter { + private ArrayList historyList; + private MoldeMapHistoryRecyclerViewAdapterCallback callback; + private Context context; + private Cache cache; + + public MoldeMapHistroyRecyclerViewAdapter(ArrayList historyList, + Context context) { + this.historyList = historyList; + this.context = context; + } + + public static class MapHistoryViewHolder extends RecyclerView.ViewHolder { + @BindView(R.id.history_title) + TextView history_title; + @BindView(R.id.history_delete_button) + ImageButton history_delete_button; + + public MapHistoryViewHolder(View itemView) { + super(itemView); + ButterKnife.bind(this, itemView); + } + } + + @Override + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.map_list_item_history_info, parent, false); + return new MapHistoryViewHolder(view); + } + + @Override + public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) { + if (holder instanceof MapHistoryViewHolder) { + final MapHistoryViewHolder viewHolder = (MapHistoryViewHolder) holder; + cache = new Cache(context); + viewHolder.history_title.setText(historyList.get(position).getName()); + viewHolder.history_delete_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + String keywordHistoryStr = ""; + if(historyList.size() <= 1){ + historyList.remove(position); + notifyItemRemoved(position); + try { + cache.Write(keywordHistoryStr); + return; + } catch (IOException e) { + e.printStackTrace(); + } + } + + try { + notifyItemRemoved(position); + historyList.remove(position); + Collections.reverse(historyList); + for(int i = 0; i < historyList.size(); i++){ + keywordHistoryStr += + historyList.get(i).getMapLat() + + "|" + historyList.get(i).getMapLng() + + "|" + historyList.get(i).getName() + + "|" + historyList.get(i).getMainAddress() + + "|" + historyList.get(i).getBizName() + + "|" + historyList.get(i).getTelNo() + ","; + + } + cache.Write(keywordHistoryStr); + } catch (IOException e) { + e.printStackTrace(); + } + } + }); + + viewHolder.itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + try { + callback.applyHistoryMapInfo(new MoldeSearchMapHistoryEntity( + historyList.get(position).getMapLat(), + historyList.get(position).getMapLng(), + historyList.get(position).getName(), + historyList.get(position).getMainAddress(), + historyList.get(position).getBizName(), + historyList.get(position).getTelNo() + ) + ); + }catch (IndexOutOfBoundsException e) { + Log.e("맵 정보", + historyList.get(0).getName() + ", " + + historyList.get(0).getMapLat() + ", " + + historyList.get(0).getMapLng() + ", " + + historyList.get(0).getBizName() + ", " + + historyList.get(0).getMainAddress() + ", " + + historyList.get(0).getTelNo()); + callback.applyHistoryMapInfo(new MoldeSearchMapHistoryEntity( + historyList.get(0).getMapLat(), + historyList.get(0).getMapLng(), + historyList.get(0).getName(), + historyList.get(0).getMainAddress(), + historyList.get(0).getBizName(), + historyList.get(0).getTelNo() + ) + ); + } + MoldeSearchMapInfoActivity.checkBackPressed = false; + } + }); + } + } + + @Override + public int getItemCount() { + return historyList.size(); + } + + public void setCallback(MoldeMapHistoryRecyclerViewAdapterCallback callback) { + this.callback = callback; + } + + +} diff --git a/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapInfoRecyclerViewAdapter.java b/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapInfoRecyclerViewAdapter.java index 3499186..21465fc 100755 --- a/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapInfoRecyclerViewAdapter.java +++ b/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapInfoRecyclerViewAdapter.java @@ -2,56 +2,170 @@ import com.limefriends.molde.R; import com.limefriends.molde.menu_map.autosearch.SearchPoiParse; +import com.limefriends.molde.menu_map.cacheManager.Cache; +import com.limefriends.molde.menu_map.entity.MoldeSearchMapInfoEntity; +import android.content.Context; +import android.content.res.Resources; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; +import android.widget.ToggleButton; + +import java.io.IOException; import java.util.ArrayList; import java.util.concurrent.ExecutionException; +import butterknife.BindView; +import butterknife.ButterKnife; + -public class MoldeMapInfoRecyclerViewAdapter extends RecyclerView.Adapter{ +public class MoldeMapInfoRecyclerViewAdapter extends RecyclerView.Adapter { - private ArrayList itemLists = new ArrayList<>(); + private ArrayList infoList = new ArrayList<>(); private MoldeMapInfoRecyclerViewAdapterCallback callback; + private String keywordHistory; + private Context context; + private Cache cache; + + public MoldeMapInfoRecyclerViewAdapter(Context context) { + this.context = context; + } - public static class CustomViewHolder extends RecyclerView.ViewHolder { - public TextView title; - public TextView address; - public String mapLat; - public String mapLng; - public CustomViewHolder(View itemView) { + public static class MapInfoViewHolder extends RecyclerView.ViewHolder { + @BindView(R.id.map_info_title) + TextView map_info_title; + @BindView(R.id.map_info_address) + TextView map_info_address; + @BindView(R.id.check_favorite_toggle) + ToggleButton check_favorite_toggle; + + private String name; + private String mainAddress; + private String streetAddress; + private String mapLat; + private String mapLng; + private String bizName; + private String telNo; + + public MapInfoViewHolder(View itemView) { super(itemView); - title = (TextView) itemView.findViewById(R.id.map_info_title); - address = (TextView) itemView.findViewById(R.id.map_info_address); + ButterKnife.bind(this, itemView); } } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.map_info_list_item, parent, false); - return new CustomViewHolder(view); + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.map_list_item_loc_info, parent, false); + return new MapInfoViewHolder(view); } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { - final int ItemPosition = position; - - if( holder instanceof CustomViewHolder) { - final CustomViewHolder viewHolder = (CustomViewHolder)holder; - - viewHolder.title.setText(itemLists.get(position).getTitle()); - viewHolder.address.setText(itemLists.get(position).getAddress()); - - viewHolder.mapLat = itemLists.get(position).getMapLat(); - viewHolder.mapLng = itemLists.get(position).getMapLng(); + //final int ItemPosition = position; + final Resources res = holder.itemView.getContext().getResources(); + if (holder instanceof MapInfoViewHolder) { + final MapInfoViewHolder viewHolder = (MapInfoViewHolder) holder; + viewHolder.map_info_title.setText(infoList.get(position).getName()); + viewHolder.map_info_address.setText(infoList.get(position).getMainAddress()); + + viewHolder.mapLat = infoList.get(position).getMapLat(); + viewHolder.mapLng = infoList.get(position).getMapLng(); + viewHolder.name = infoList.get(position).getName(); + viewHolder.mainAddress = infoList.get(position).getMainAddress(); + if(viewHolder.mainAddress == null || viewHolder.mainAddress.equals("")){ + viewHolder.mainAddress = "정보 없음"; + } + viewHolder.bizName = infoList.get(position).getBizName(); + if(viewHolder.bizName == null || viewHolder.bizName.equals("")){ + viewHolder.bizName = "정보 없음"; + } + viewHolder.telNo = infoList.get(position).getTelNo(); + if(viewHolder.telNo == null || viewHolder.telNo.equals("")){ + viewHolder.telNo = "정보 없음"; + } + viewHolder.streetAddress = infoList.get(position).getStreetAddress(); + if(viewHolder.streetAddress == null || viewHolder.streetAddress.equals("")){ + viewHolder.streetAddress = "정보 없음"; + } viewHolder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - callback.showToast(viewHolder.mapLat + ", " + viewHolder.mapLng); + if(keywordHistory == null || keywordHistory.equals("")){ + cache = new Cache(context); + try { + keywordHistory = + viewHolder.mapLat + + "|" + viewHolder.mapLng + + "|" + viewHolder.name + + "|" + viewHolder.mainAddress + + "|" + viewHolder.bizName + + "|" + viewHolder.telNo + ","; + cache.Write(keywordHistory); + } catch (IOException e) { + e.printStackTrace(); + } + } + //callback.showToast(viewHolder.mapLat + ", " + viewHolder.mapLng + " : " + viewHolder.bizName + " - " + viewHolder.telNo); + String[] keywordHistoryArray = keywordHistory.split(","); + ArrayList keywordHistoryList = new ArrayList(); + for (int i = 0; i < keywordHistoryArray.length; i++) { + keywordHistoryList.add(keywordHistoryArray[i]); + } + for (int i = 0; i < keywordHistoryList.size(); i++) { + if (keywordHistoryList.get(i).contains(viewHolder.mapLat + "|" + viewHolder.mapLng + "|" + viewHolder.name)) { + keywordHistoryList.remove(i); + } + } + keywordHistory = ""; + for (int i = 0; i < keywordHistoryList.size(); i++) { + keywordHistory += keywordHistoryList.get(i) + ","; + } + callback.applyMapInfo( + new MoldeSearchMapInfoEntity( + viewHolder.mapLat, + viewHolder.mapLng, + viewHolder.name, + viewHolder.mainAddress, + viewHolder.streetAddress, + viewHolder.bizName, + viewHolder.telNo + ) + ); + MoldeSearchMapInfoActivity.checkBackPressed = false; + try { + callback.writeSearchMapHistory( + new MoldeSearchMapInfoEntity( + viewHolder.mapLat, + viewHolder.mapLng, + viewHolder.name, + viewHolder.mainAddress, + viewHolder.streetAddress, + viewHolder.bizName, + viewHolder.telNo + ), keywordHistory + ); + } catch (IOException e) { + e.printStackTrace(); + } + } + }); + + viewHolder.check_favorite_toggle.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(viewHolder.check_favorite_toggle.isChecked()){ + viewHolder.check_favorite_toggle.setBackgroundDrawable( + res.getDrawable(R.drawable.star_on) + ); + }else{ + viewHolder.check_favorite_toggle.setBackgroundDrawable( + res.getDrawable(R.drawable.star_off) + ); + } } }); } @@ -59,22 +173,23 @@ public void onClick(View v) { @Override public int getItemCount() { - return itemLists.size(); + return infoList.size(); } public void setData(ArrayList itemLists) { - this.itemLists = itemLists; + this.infoList = itemLists; } public void setCallback(MoldeMapInfoRecyclerViewAdapterCallback callback) { this.callback = callback; } - public void filter(String keyword) { + public void filter(String keyword, String keywordHistoryStr) { + keywordHistory = keywordHistoryStr; if (keyword.length() >= 2) { try { SearchPoiParse parser = new SearchPoiParse(this); - itemLists.addAll(parser.execute(keyword).get()); + infoList.addAll(parser.execute(keyword).get()); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { diff --git a/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapInfoRecyclerViewAdapterCallback.java b/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapInfoRecyclerViewAdapterCallback.java index 0a446b9..dc04d3e 100755 --- a/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapInfoRecyclerViewAdapterCallback.java +++ b/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapInfoRecyclerViewAdapterCallback.java @@ -1,7 +1,12 @@ package com.limefriends.molde.menu_map; +import com.limefriends.molde.menu_map.entity.MoldeSearchMapInfoEntity; + +import java.io.IOException; + public interface MoldeMapInfoRecyclerViewAdapterCallback { void showToast(String toast); - void applyMapInfo(int position); + void applyMapInfo(MoldeSearchMapInfoEntity entity); + void writeSearchMapHistory(MoldeSearchMapInfoEntity entity, String historyStr) throws IOException; } diff --git a/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapReportPagerAdapterCallback.java b/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapReportPagerAdapterCallback.java new file mode 100755 index 0000000..9a13d16 --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/MoldeMapReportPagerAdapterCallback.java @@ -0,0 +1,5 @@ +package com.limefriends.molde.menu_map; + +public interface MoldeMapReportPagerAdapterCallback { + void applyReportCardInfo(int position); +} diff --git a/app/src/main/java/com/limefriends/molde/menu_map/MoldeReportActivity.java b/app/src/main/java/com/limefriends/molde/menu_map/MoldeReportActivity.java new file mode 100644 index 0000000..2481855 --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/MoldeReportActivity.java @@ -0,0 +1,46 @@ +package com.limefriends.molde.menu_map; + +import android.annotation.SuppressLint; +import android.content.Intent; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; + +import com.limefriends.molde.MoldeMainActivity; +import com.limefriends.molde.R; + +public class MoldeReportActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.map_activity_molde_report); + + getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); + getSupportActionBar().setCustomView(R.layout.custom_toolbar); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setHomeButtonEnabled(true); + getSupportActionBar().setDisplayShowTitleEnabled(false); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.actionbar_menu, menu); + return true; + } + + @Override + public void onBackPressed() { + MoldeSearchMapInfoActivity.checkBackPressed = true; + MoldeMapFragment mapFragment = new MoldeMapFragment(); + Intent intent = new Intent(); + intent.setClass(getApplicationContext(), MoldeMainActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + } + + + +} diff --git a/app/src/main/java/com/limefriends/molde/menu_map/MoldeSearchMapInfoActivity.java b/app/src/main/java/com/limefriends/molde/menu_map/MoldeSearchMapInfoActivity.java index 208311c..c05d711 100644 --- a/app/src/main/java/com/limefriends/molde/menu_map/MoldeSearchMapInfoActivity.java +++ b/app/src/main/java/com/limefriends/molde/menu_map/MoldeSearchMapInfoActivity.java @@ -1,7 +1,12 @@ package com.limefriends.molde.menu_map; +import com.limefriends.molde.MoldeMainActivity; import com.limefriends.molde.R; +import com.limefriends.molde.menu_map.cacheManager.Cache; +import com.limefriends.molde.menu_map.entity.MoldeSearchMapHistoryEntity; +import com.limefriends.molde.menu_map.entity.MoldeSearchMapInfoEntity; +import android.content.Intent; import android.os.Handler; import android.os.Looper; import android.support.v7.app.AppCompatActivity; @@ -9,38 +14,85 @@ import android.support.v7.widget.LinearLayoutManager; import android.text.Editable; import android.text.TextWatcher; +import android.util.Log; +import android.view.KeyEvent; import android.view.View; +import android.view.inputmethod.EditorInfo; import android.widget.EditText; import android.widget.ImageButton; import android.widget.LinearLayout; import android.support.v7.widget.RecyclerView; +import android.widget.TextView; import android.widget.Toast; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; + import butterknife.BindView; import butterknife.ButterKnife; -public class MoldeSearchMapInfoActivity extends AppCompatActivity implements MoldeMapInfoRecyclerViewAdapterCallback { +public class MoldeSearchMapInfoActivity extends AppCompatActivity + implements MoldeMapInfoRecyclerViewAdapterCallback, + MoldeMapHistoryRecyclerViewAdapterCallback{ @BindView(R.id.loc_map_info_search_bar) LinearLayout loc_map_info_search_bar; @BindView(R.id.loc_map_info_search_input) EditText loc_map_info_search_input; @BindView(R.id.loc_map_info_search_button) ImageButton loc_map_info_search_button; + @BindView(R.id.history_map_info_list) + RecyclerView history_map_info_list; @BindView(R.id.loc_map_info_list) RecyclerView loc_map_info_list; + @BindView(R.id.delete_all_button) + ImageButton delete_all_button; + //private FileCache fileCache; + public static boolean checkBackPressed = false; private MoldeMapInfoRecyclerViewAdapter loc_map_info_list_adapter; + private MoldeMapHistroyRecyclerViewAdapter history_map_info_list_adapter; private Handler handler = new Handler(Looper.getMainLooper()); private Runnable workRunnable; private final long DELAY = 100; + private Cache cache; + private String keywordHistoryStr; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_molde_search_map_info); + setContentView(R.layout.map_activity_molde_search_info); ButterKnife.bind(this); loc_map_info_search_bar.setElevation(12); + Intent intent = getIntent(); + String name = intent.getStringExtra("searchName"); + if (name.equals("검색하기")) { + loc_map_info_search_input.setText(""); + } else { + loc_map_info_search_input.setText(name); + } + loc_map_info_search_input.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) { + if(actionId == EditorInfo.IME_ACTION_SEARCH){ + loc_map_info_search_button.performClick(); + return true; + }else if(actionId == EditorInfo.IME_ACTION_DONE){ + loc_map_info_search_button.performClick(); + return true; + } + return false; + } + }); + searchFieldInit(); + historyFieldInit(); + delete_all_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + loc_map_info_search_input.setText(""); + } + }); } @Override @@ -49,17 +101,31 @@ public void showToast(String toast) { } @Override - public void applyMapInfo(int position) { + public void applyMapInfo(MoldeSearchMapInfoEntity entity) { + Intent intent = new Intent(); + intent.setClass(getApplicationContext(), MoldeMainActivity.class); + intent.putExtra("mapInfo", entity); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + } + @Override + public void writeSearchMapHistory(MoldeSearchMapInfoEntity entity, String historyStr) throws IOException { + String history = entity.getMapLat() + "|" + entity.getMapLng() + "|" + entity.getName() + "|" + entity.getMainAddress() + "|" + entity.getBizName() + "|" + entity.getTelNo(); + keywordHistoryStr = historyStr; + keywordHistoryStr += history + ","; + cache.Write(keywordHistoryStr); } private void searchFieldInit() { loc_map_info_search_input.addTextChangedListener(new TextWatcher() { @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) {} + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } @Override - public void onTextChanged(CharSequence s, int start, int before, int count) {} + public void onTextChanged(CharSequence s, int start, int before, int count) { + } @Override public void afterTextChanged(Editable s) { @@ -79,11 +145,13 @@ public void run() { @Override public void onClick(View view) { searchMapInfoList(); + history_map_info_list.setVisibility(View.INVISIBLE); } }); + //검색 정보 띄우기 RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this); - loc_map_info_list_adapter = new MoldeMapInfoRecyclerViewAdapter(); + loc_map_info_list_adapter = new MoldeMapInfoRecyclerViewAdapter(getApplicationContext()); loc_map_info_list.setLayoutManager(layoutManager); loc_map_info_list.setAdapter(loc_map_info_list_adapter); loc_map_info_list_adapter.setCallback(this); @@ -95,9 +163,77 @@ private void searchMapInfoList() { workRunnable = new Runnable() { @Override public void run() { - loc_map_info_list_adapter.filter(keyword); + loc_map_info_list_adapter.filter(keyword, keywordHistoryStr); } }; handler.postDelayed(workRunnable, DELAY); } + + private void historyFieldInit() { + cache = new Cache(getApplicationContext()); + try { + keywordHistoryStr = cache.Read(); + //cache.Write(""); + } catch (IOException e) { + e.printStackTrace(); + } + if (keywordHistoryStr.equals("")) { + return; + } else { + keywordHistoryStr = keywordHistoryStr.trim(); + if (keywordHistoryStr.charAt(0) == ',') { + keywordHistoryStr = keywordHistoryStr.substring(0, 1); + try { + cache.Write(keywordHistoryStr); + } catch (IOException e) { + e.printStackTrace(); + } + return; + } else { + makeHistoryList(keywordHistoryStr); + } + } + Log.e("history", keywordHistoryStr); + } + + private void makeHistoryList(String keywordHistoryStr) { + String[] historyArray = keywordHistoryStr.split(","); + ArrayList historyEntityList = new ArrayList(); + for (int i = 0; i < historyArray.length; i++) { + String[] historyElem = historyArray[i].split("\\|"); + MoldeSearchMapHistoryEntity historyEntity; + String mapLat = historyElem[0]; + String mapLng = historyElem[1]; + String name = historyElem[2]; + String mainAddr = historyElem[3]; + String bizName = historyElem[4]; + String telNo = historyElem[5]; + historyEntity = new MoldeSearchMapHistoryEntity(mapLat, mapLng, name, mainAddr, bizName, telNo); + historyEntityList.add(historyEntity); + } + + Collections.reverse(historyEntityList); + //검색 기록 띄우기 + RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this); + history_map_info_list_adapter = new MoldeMapHistroyRecyclerViewAdapter(historyEntityList, getApplicationContext()); + history_map_info_list.setLayoutManager(layoutManager); + history_map_info_list.setAdapter(history_map_info_list_adapter); + history_map_info_list_adapter.setCallback(this); + } + + @Override + public void applyHistoryMapInfo(MoldeSearchMapHistoryEntity historyEntity) { + Intent intent = new Intent(); + intent.setClass(getApplicationContext(), MoldeMainActivity.class); + intent.putExtra("mapHistoryInfo", historyEntity); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + } + + @Override + public void onBackPressed() { + super.onBackPressed(); + checkBackPressed = true; + + } } diff --git a/app/src/main/java/com/limefriends/molde/menu_map/MoldeSearchMapInfoEntity.java b/app/src/main/java/com/limefriends/molde/menu_map/MoldeSearchMapInfoEntity.java deleted file mode 100755 index 709b926..0000000 --- a/app/src/main/java/com/limefriends/molde/menu_map/MoldeSearchMapInfoEntity.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.limefriends.molde.menu_map; - - -public class MoldeSearchMapInfoEntity { - private String title; - private String address; - private String mapLat; - private String mapLng; - - public MoldeSearchMapInfoEntity(String title, String address, String mapLat, String mapLng) { - this.title = title; - this.address = address; - this.mapLat = mapLat; - this.mapLng = mapLng; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - public String getMapLat() { - return mapLat; - } - - public void setMapLat(String centLat) { - this.mapLat = centLat; - } - - public String getMapLng() { - return mapLng; - } - - public void setMapLng(String centLng) { - this.mapLng = centLng; - } -} diff --git a/app/src/main/java/com/limefriends/molde/menu_map/autosearch/Poi.java b/app/src/main/java/com/limefriends/molde/menu_map/autosearch/Poi.java index 3528783..e72ce79 100755 --- a/app/src/main/java/com/limefriends/molde/menu_map/autosearch/Poi.java +++ b/app/src/main/java/com/limefriends/molde/menu_map/autosearch/Poi.java @@ -2,32 +2,59 @@ public class Poi { + //POI 의 id private String id; + //POI 의 name private String name; + //POI 에 대한 전화번호 private String telNo; + //시설물 입구 위도 좌표 private String frontLat; + //시설물 입구 경도 좌표 private String frontLon; + //중심점 위도 좌표 private String noorLat; + //중심점 경도 좌표 private String noorLon; + //표출 주소 대분류명 private String upperAddrName; + //표출 주소 중분류명 private String middleAddrName; + //표출 주소 소분류명 private String lowerAddrName; + //표출 주소 세분류명 private String detailAddrName; - private String mlClass; + //본번 private String firstNo; + //부번 private String secondNo; + //도로명 private String roadName; + //건물번호 1 private String firstBuildNo; + //건물번호 2 private String secondBuildNo; + //업종 대분류명 + private String mlClass; + //거리(km) private String radius; + //업소명 private String bizName; + //시설목적 private String upperBizName; + //시설분류 private String middleBizName; + //시설이름 ex) 지하철역 병원 등 private String lowerBizName; + //상세 이름 private String detailBizName; + //길안내 요청 유무 private String rpFlag; + //주차 가능유무 private String parkFlag; + //POI 상세정보 유무 private String detailInfoFlag; + //소개 정보 private String desc; public String getId() { diff --git a/app/src/main/java/com/limefriends/molde/menu_map/autosearch/SearchPoiParse.java b/app/src/main/java/com/limefriends/molde/menu_map/autosearch/SearchPoiParse.java index 68ecb87..d4dea2d 100755 --- a/app/src/main/java/com/limefriends/molde/menu_map/autosearch/SearchPoiParse.java +++ b/app/src/main/java/com/limefriends/molde/menu_map/autosearch/SearchPoiParse.java @@ -4,7 +4,7 @@ import com.google.gson.Gson; import com.limefriends.molde.menu_map.MoldeMapInfoRecyclerViewAdapter; -import com.limefriends.molde.menu_map.MoldeSearchMapInfoEntity; +import com.limefriends.molde.menu_map.entity.MoldeSearchMapInfoEntity; import java.io.BufferedReader; import java.io.IOException; @@ -18,12 +18,12 @@ public class SearchPoiParse extends AsyncTask> { private final String TMAP_API_KEY = "846fd0ff-fac4-4e07-9c7c-1950cc0131dd"; private final int SEARCH_COUNT = 20; // minimum is 20 - private ArrayList mListData; + private ArrayList searchMapListData; private MoldeMapInfoRecyclerViewAdapter mAdapter; public SearchPoiParse(MoldeMapInfoRecyclerViewAdapter adapter) { this.mAdapter = adapter; - mListData = new ArrayList(); + searchMapListData = new ArrayList(); } @Override @@ -68,26 +68,34 @@ public ArrayList getAutoComplete(String word) { String line = reader.readLine(); if (line == null) { - mListData.clear(); - return mListData; + searchMapListData.clear(); + return searchMapListData; } reader.close(); - mListData.clear(); + //Log.e("response", line); + TMapSearchInfo searchPoiInfo = new Gson().fromJson(line, TMapSearchInfo.class); ArrayList poi = searchPoiInfo.getSearchPoiInfo().getPois().getPoi(); for (int i = 0; i < poi.size(); i++) { - String fullAddr = poi.get(i).getUpperAddrName() + " " + poi.get(i).getMiddleAddrName() + - " " + poi.get(i).getLowerAddrName() + " " + poi.get(i).getDetailAddrName(); - mListData.add(new MoldeSearchMapInfoEntity(poi.get(i).getName(), fullAddr, poi.get(i).getFrontLat(), poi.get(i).getFrontLon())); + String mainAddr = ""; + if(poi.get(i).getSecondNo() == null || poi.get(i).getSecondNo().trim().equals("")){ + mainAddr = poi.get(i).getUpperAddrName().trim() + " " + poi.get(i).getMiddleAddrName().trim() + + " " + poi.get(i).getLowerAddrName().trim() + " " + poi.get(i).getDetailAddrName().trim() + " " + poi.get(i).getFirstNo().trim(); + }else{ + mainAddr = poi.get(i).getUpperAddrName().trim() + " " + poi.get(i).getMiddleAddrName().trim() + + " " + poi.get(i).getLowerAddrName().trim() + " " + poi.get(i).getDetailAddrName().trim() + " " + poi.get(i).getFirstNo().trim() + "-" + poi.get(i).getSecondNo().trim(); + } + String streetAddr = poi.get(i).getRoadName().trim() + " " + poi.get(i).getFirstBuildNo().trim(); + searchMapListData.add(new MoldeSearchMapInfoEntity(poi.get(i).getNoorLat(), poi.get(i).getNoorLon(), poi.get(i).getName(), mainAddr, streetAddr, poi.get(i).getLowerBizName(), poi.get(i).getTelNo())); } } catch (IOException e) { e.printStackTrace(); } - return mListData; + return searchMapListData; } } diff --git a/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/ByteProvider.java b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/ByteProvider.java new file mode 100644 index 0000000..6b37def --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/ByteProvider.java @@ -0,0 +1,8 @@ +package com.limefriends.molde.menu_map.cacheManager; + +import java.io.IOException; +import java.io.OutputStream; + +public interface ByteProvider { + void writeTo(OutputStream os) throws IOException; +} diff --git a/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/ByteProviderUtil.java b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/ByteProviderUtil.java new file mode 100644 index 0000000..1a2c67a --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/ByteProviderUtil.java @@ -0,0 +1,36 @@ +package com.limefriends.molde.menu_map.cacheManager; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +public abstract class ByteProviderUtil { + + public static ByteProvider create(final InputStream is) { + return new ByteProvider() { + @Override + public void writeTo(OutputStream os) throws IOException { + IOUtils.copy(is, os); + } + }; + } + + public static ByteProvider create(final File file) { + return new ByteProvider() { + @Override + public void writeTo(OutputStream os) throws IOException { + IOUtils.copy(file, os); + } + }; + } + + public static ByteProvider create(final String str) { + return new ByteProvider() { + @Override + public void writeTo(OutputStream os) throws IOException { + IOUtils.copy(str, os); + } + }; + } +} diff --git a/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/Cache.java b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/Cache.java new file mode 100644 index 0000000..c6264bc --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/Cache.java @@ -0,0 +1,60 @@ +package com.limefriends.molde.menu_map.cacheManager; + +import android.content.Context; +import android.os.Environment; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Scanner; + +public class Cache { + Context context; + + public Cache(Context co) { + context = co; + } + + public File getCacheDir(Context context) { + File cacheDir = null; + if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { + cacheDir = new File(Environment.getExternalStorageDirectory(), "cachefolder"); + if (!cacheDir.isDirectory()) { + cacheDir.mkdirs(); + } + } + if (!cacheDir.isDirectory()) { + cacheDir = context.getCacheDir(); + } + return cacheDir; + } + + public void Write(String cache) throws IOException { + File cacheDir = getCacheDir(context); + File cacheFile = new File(cacheDir, "mapInfoSearchHistory.txt"); + if (!cacheFile.exists()) cacheFile.createNewFile(); + FileWriter fileWriter = new FileWriter(cacheFile); + fileWriter.write(cache); + fileWriter.flush(); + fileWriter.close(); + } + + public String Read() throws IOException { + File cacheDir = getCacheDir(context); + File cacheFile = new File(cacheDir, "mapInfoSearchHistory.txt"); + if (!cacheFile.exists()) cacheFile.createNewFile(); + FileInputStream inputStream = new FileInputStream(cacheFile); + Scanner s = new Scanner(inputStream); + String text = ""; + while (s.hasNext()) { + text += s.nextLine(); + } + inputStream.close(); + return text; + } + + public void Delete() throws IOException { + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/CacheStorage.java b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/CacheStorage.java new file mode 100644 index 0000000..01bcc71 --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/CacheStorage.java @@ -0,0 +1,217 @@ +package com.limefriends.molde.menu_map.cacheManager; + + +import android.util.Log; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +public class CacheStorage { + private static final String TAG = "CacheStorage"; + + private File cacheDir; + private Map cacheFileMap; + + private long maxBytesSize; + private AtomicLong currentBytesSize = new AtomicLong(); + + private ReadWriteLock rwl = new ReentrantReadWriteLock(); + private Lock readLock = rwl.readLock(); + private Lock writeLock = rwl.writeLock(); + + public CacheStorage(File cacheDir, long maxBytesSize) { + this.cacheDir = cacheDir; + this.maxBytesSize = maxBytesSize; + this.cacheFileMap = Collections + .synchronizedMap(new LinkedHashMap(1024)); + + createCacheDirIfNotExists(); + initializing(); + } + + private void createCacheDirIfNotExists() { + if (cacheDir.exists()) + return; + cacheDir.mkdirs(); + } + + private void initializing() { + new Thread(new Initializer()).start(); + } + + private class Initializer implements Runnable { + + @Override + public void run() { + writeLock.lock(); + try { + File[] cachedFiles = cacheDir.listFiles(); + for (File file : cachedFiles) { + putFileToCacheMap(file); + } + } catch (Exception ex) { + Log.e(TAG, "CacheStorage.Initializer: fail to initialize - " + + ex.getMessage(), ex); + } finally { + writeLock.unlock(); + } + } + } + + public File get(String filename) { + readLock.lock(); + try { + CacheFile cachdFile = cacheFileMap.get(filename); + if (cachdFile == null) { + return null; + } + if (cachdFile.file.exists()) { + moveHitEntryToFirst(filename, cachdFile); + return cachdFile.file; + } + removeCacheFileFromMap(filename, cachdFile); + return null; + } finally { + readLock.unlock(); + } + } + + private void moveHitEntryToFirst(String filename, CacheFile cachedFile) { + cacheFileMap.remove(filename); + cacheFileMap.put(filename, cachedFile); + } + + private void removeCacheFileFromMap(String filename, CacheFile cachedFile) { + currentBytesSize.addAndGet(-cachedFile.size); + cacheFileMap.remove(filename); + } + + public void write(String filename, ByteProvider provider) throws IOException { + writeLock.lock(); + try { + createCacheDirIfNotExists(); + File file = createFile(filename); + copyProviderToFile(provider, file); + putToCachMapAndCheckMaxThresold(file); + } finally { + writeLock.unlock(); + } + } + + private File createFile(String filename) { + return new File(cacheDir, filename); + } + + private void copyProviderToFile(ByteProvider provider, File file) + throws FileNotFoundException, IOException { + BufferedOutputStream os = null; + try { + os = new BufferedOutputStream(new FileOutputStream(file)); + provider.writeTo(os); + } finally { + IOUtils.close(os); + } + } + + private void putToCachMapAndCheckMaxThresold(File file) { + putFileToCacheMap(file); + checkMaxThresoldAndDeleteOldestWhenOverflow(); + } + + private void putFileToCacheMap(File file) { + cacheFileMap.put(file.getName(), new CacheFile(file)); + currentBytesSize.addAndGet(file.length()); + } + + private void checkMaxThresoldAndDeleteOldestWhenOverflow() { + if (isOverflow()) { + List> deletingCandidates = getDeletingCandidates(); + for (Entry entry : deletingCandidates) { + delete(entry.getKey()); + } + } + } + + private boolean isOverflow() { + if (maxBytesSize <= 0) { + return false; + } + return currentBytesSize.get() > maxBytesSize; + } + + private List> getDeletingCandidates() { + List> deletingCandidates = + new ArrayList>(); + long cadidateFileSizes = 0; + for (Entry entry : cacheFileMap.entrySet()) { + deletingCandidates.add(entry); + cadidateFileSizes += entry.getValue().file.length(); + if (currentBytesSize.get() - cadidateFileSizes < maxBytesSize) { + break; + } + } + return deletingCandidates; + } + + public void move(String filename, File sourceFile) { + writeLock.lock(); + try { + createCacheDirIfNotExists(); + File file = createFile(filename); + sourceFile.renameTo(file); + putToCachMapAndCheckMaxThresold(file); + } finally { + writeLock.unlock(); + } + } + + public void delete(String filename) { + writeLock.lock(); + try { + CacheFile cacheFile = cacheFileMap.get(filename); + if (cacheFile == null) + return; + + removeCacheFileFromMap(filename, cacheFile); + cacheFile.file.delete(); + } finally { + writeLock.unlock(); + } + } + + public void deleteAll() { + writeLock.lock(); + try { + List keys = new ArrayList(cacheFileMap.keySet()); + for (String key : keys) { + delete(key); + } + } finally { + writeLock.unlock(); + } + } + + private static class CacheFile { + public File file; + public long size; + + public CacheFile(File file) { + super(); + this.file = file; + this.size = file.length(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/FileCache.java b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/FileCache.java new file mode 100644 index 0000000..9f50bb7 --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/FileCache.java @@ -0,0 +1,20 @@ +package com.limefriends.molde.menu_map.cacheManager; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; + +public interface FileCache { + + public FileEntry get(String key); + + public void put(String key, ByteProvider provider) throws IOException; + + public void put(String key, InputStream is) throws IOException; + + public void put(String key, File sourceFile, boolean move) throws IOException; + + public void remove(String key); + + public void clear(); +} diff --git a/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/FileCacheAleadyExistException.java b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/FileCacheAleadyExistException.java new file mode 100644 index 0000000..db4df5a --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/FileCacheAleadyExistException.java @@ -0,0 +1,9 @@ +package com.limefriends.molde.menu_map.cacheManager; + +import android.util.Log; + +public class FileCacheAleadyExistException extends Throwable { + public FileCacheAleadyExistException(String format) { + Log.e("CacheAleadyExistE", format); + } +} diff --git a/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/FileCacheFactory.java b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/FileCacheFactory.java new file mode 100644 index 0000000..e89ffb2 --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/FileCacheFactory.java @@ -0,0 +1,70 @@ +package com.limefriends.molde.menu_map.cacheManager; + +import android.content.Context; + +import java.io.File; +import java.util.HashMap; + +public class FileCacheFactory { + + private static boolean initialized = false; + private static FileCacheFactory instance = new FileCacheFactory(); + + public static void initialize(Context context) { + if (!initialized) { + synchronized (instance) { + if (!initialized) { + instance.init(context); + initialized = true; + } + } + } + } + + public static FileCacheFactory getInstance() { + if (!initialized) { + throw new IllegalStateException( + "Not initialized. You must call FileCacheFactory.initialize() before getInstance()"); + } + return instance; + } + + private HashMap cacheMap = new HashMap(); + private File cacheBaseDir; + + private FileCacheFactory() { + } + + private void init(Context context) { + cacheBaseDir = context.getCacheDir(); + } + + public FileCache create(String cacheName, int maxKbSizes) throws FileCacheAleadyExistException { + synchronized (cacheMap) { + FileCache cache = cacheMap.get(cacheName); + if (cache != null) { + throw new FileCacheAleadyExistException(String.format( + "FileCache[%s] Aleady exists", cacheName)); + } + File cacheDir = new File(cacheBaseDir, cacheName); + cache = new FileCacheImpl(cacheDir, maxKbSizes); + cacheMap.put(cacheName, cache); + return cache; + } + } + + public FileCache get(String cacheName) throws FileCacheNotFoundException { + synchronized (cacheMap) { + FileCache cache = cacheMap.get(cacheName); + if (cache == null) { + throw new FileCacheNotFoundException(String.format( + "FileCache[%s] not founds.", cacheName)); + } + return cache; + } + } + + public boolean has(String cacheName) { + return cacheMap.containsKey(cacheName); + } +} diff --git a/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/FileCacheImpl.java b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/FileCacheImpl.java new file mode 100644 index 0000000..d847f9b --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/FileCacheImpl.java @@ -0,0 +1,71 @@ +package com.limefriends.molde.menu_map.cacheManager; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; + +public class FileCacheImpl implements FileCache { + + private CacheStorage cacheStorage; + + public FileCacheImpl(File cacheDir, int maxKBSizes) { + long maxBytesSize = maxKBSizes <= 0 ? 0 : maxKBSizes * 1024; + cacheStorage = new CacheStorage(cacheDir, maxBytesSize); + } + + @Override + public FileEntry get(String key) { + File file = cacheStorage.get(keyToFilename(key)); + if (file == null) { + return null; + } + if (file.exists()) { + return new FileEntry(key, file); + } + return null; + } + + @Override + public void put(String key, ByteProvider provider) throws IOException { + cacheStorage.write(keyToFilename(key), provider); + } + + @Override + public void put(String key, InputStream is) throws IOException { + put(key, ByteProviderUtil.create(is)); + } + + @Override + public void put(String key, File sourceFile, boolean move) + throws IOException { + if (move) { + cacheStorage.move(keyToFilename(key), sourceFile); + } else { + put(key, ByteProviderUtil.create(sourceFile)); + } + } + + @Override + public void remove(String key) { + cacheStorage.delete(keyToFilename(key)); + } + + private String keyToFilename(String key) { + String filename = key.replace(":", "_"); + filename = filename.replace("/", "_s_"); + filename = filename.replace("\\", "_bs_"); + filename = filename.replace("&", "_bs_"); + filename = filename.replace("*", "_start_"); + filename = filename.replace("?", "_q_"); + filename = filename.replace("|", "_or_"); + filename = filename.replace(">", "_gt_"); + filename = filename.replace("<", "_lt_"); + return filename; + } + + @Override + public void clear() { + cacheStorage.deleteAll(); + } + +} diff --git a/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/FileCacheNotFoundException.java b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/FileCacheNotFoundException.java new file mode 100644 index 0000000..008b50e --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/FileCacheNotFoundException.java @@ -0,0 +1,10 @@ +package com.limefriends.molde.menu_map.cacheManager; + + +import android.util.Log; + +public class FileCacheNotFoundException extends Throwable { + public FileCacheNotFoundException(String format) { + Log.e("CacheNotFoundE", format); + } +} diff --git a/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/FileEntry.java b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/FileEntry.java new file mode 100644 index 0000000..c4563a9 --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/FileEntry.java @@ -0,0 +1,31 @@ +package com.limefriends.molde.menu_map.cacheManager; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; + +public class FileEntry { + + private String key; + private File file; + + public FileEntry(String key, File file) { + this.key = key; + this.file = file; + } + + public InputStream getInputStream() throws IOException { + return new BufferedInputStream(new FileInputStream(file)); + } + + public String getKey() { + return key; + } + + public File getFile() { + return file; + } + +} diff --git a/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/IOUtils.java b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/IOUtils.java new file mode 100644 index 0000000..1d40fb1 --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/cacheManager/IOUtils.java @@ -0,0 +1,74 @@ +package com.limefriends.molde.menu_map.cacheManager; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.Closeable; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; + +public abstract class IOUtils { + + public static String read(InputStream is) throws IOException { + InputStreamReader reader = null; + try { + reader = new InputStreamReader(is); + StringBuilder builder = new StringBuilder(); + char[] readDate = new char[1024]; + int len = -1; + while ((len = reader.read(readDate)) != -1) { + builder.append(readDate, 0, len); + } + return builder.toString(); + } finally { + close(reader); + } + } + + public static void copy(InputStream is, OutputStream out) + throws IOException { + byte[] buff = new byte[4096]; + int len = -1; + while ((len = is.read(buff)) != -1) { + out.write(buff, 0, len); + } + } + + public static void copy(File source, OutputStream os) throws IOException { + BufferedInputStream is = null; + try { + is = new BufferedInputStream(new FileInputStream(source)); + IOUtils.copy(is, os); + } finally { + IOUtils.close(is); + } + } + + public static void copy(InputStream is, File target) throws IOException { + OutputStream os = null; + try { + os = new BufferedOutputStream(new FileOutputStream(target)); + IOUtils.copy(is, os); + } finally { + IOUtils.close(os); + } + } + + public static void copy(String str, OutputStream os) throws IOException { + os.write(str.getBytes()); + } + + public static void close(Closeable stream) { + if (stream != null) { + try { + stream.close(); + } catch (IOException e) { + } + } + } + +} diff --git a/app/src/main/java/com/limefriends/molde/menu_map/entity/MoldeSearchMapHistoryEntity.java b/app/src/main/java/com/limefriends/molde/menu_map/entity/MoldeSearchMapHistoryEntity.java new file mode 100644 index 0000000..2518be9 --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/entity/MoldeSearchMapHistoryEntity.java @@ -0,0 +1,75 @@ +package com.limefriends.molde.menu_map.entity; + + +import java.io.Serializable; + +public class MoldeSearchMapHistoryEntity implements Serializable{ + private String mapLat; + private String mapLng; + private String name; + private String mainAddress; + private String bizName; + private String telNo; + + public MoldeSearchMapHistoryEntity(String mapLat, String mapLng, String name, String mainAddress, String bizName, String telNo) { + this.mapLat = mapLat; + this.mapLng = mapLng; + this.name = name; + this.mainAddress = mainAddress; + this.bizName = bizName; + this.telNo = telNo; + } + + public String getMapLat() { + return mapLat; + } + + public void setMapLat(String mapLat) { + this.mapLat = mapLat; + } + + public String getMapLng() { + return mapLng; + } + + public void setMapLng(String mapLng) { + this.mapLng = mapLng; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getMainAddress() { + return mainAddress; + } + + public void setMainAddress(String mainAddress) { + this.mainAddress = mainAddress; + } + + public String getBizName() { + return bizName; + } + + public void setBizName(String bizName) { + this.bizName = bizName; + } + + public String getTelNo() { + return telNo; + } + + public void setTelNo(String telNo) { + this.telNo = telNo; + } + + @Override + public String toString() { + return name + ", " + mainAddress + ", " + bizName; + } +} diff --git a/app/src/main/java/com/limefriends/molde/menu_map/entity/MoldeSearchMapInfoEntity.java b/app/src/main/java/com/limefriends/molde/menu_map/entity/MoldeSearchMapInfoEntity.java new file mode 100755 index 0000000..137240b --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/entity/MoldeSearchMapInfoEntity.java @@ -0,0 +1,85 @@ +package com.limefriends.molde.menu_map.entity; + + +import java.io.Serializable; + +public class MoldeSearchMapInfoEntity implements Serializable{ + private String mapLat; + private String mapLng; + private String name; + private String mainAddress; + private String streetAddress; + private String bizName; + private String telNo; + + public MoldeSearchMapInfoEntity(String mapLat, String mapLng, String name, String mainAddress, String streetAddress, String bizName, String telNo) { + this.mapLat = mapLat; + this.mapLng = mapLng; + this.name = name; + this.mainAddress = mainAddress; + this.streetAddress = streetAddress; + this.bizName = bizName; + this.telNo = telNo; + } + + public String getMapLat() { + return mapLat; + } + + public void setMapLat(String mapLat) { + this.mapLat = mapLat; + } + + public String getMapLng() { + return mapLng; + } + + public void setMapLng(String mapLng) { + this.mapLng = mapLng; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getMainAddress() { + return mainAddress; + } + + public void setMainAddress(String mainAddress) { + this.mainAddress = mainAddress; + } + + public String getStreetAddress() { + return streetAddress; + } + + public void setStreetAddress(String streetAddress) { + this.streetAddress = streetAddress; + } + + public String getBizName() { + return bizName; + } + + public void setBizName(String bizName) { + this.bizName = bizName; + } + + public String getTelNo() { + return telNo; + } + + public void setTelNo(String telNo) { + this.telNo = telNo; + } + + @Override + public String toString() { + return name + ", " + mainAddress + ", " + bizName; + } +} diff --git a/app/src/main/java/com/limefriends/molde/menu_map/reportCard/ReportCardAdapter.java b/app/src/main/java/com/limefriends/molde/menu_map/reportCard/ReportCardAdapter.java new file mode 100755 index 0000000..abbead6 --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/reportCard/ReportCardAdapter.java @@ -0,0 +1,15 @@ +package com.limefriends.molde.menu_map.reportCard; + + +import android.support.v7.widget.CardView; + +public interface ReportCardAdapter { + + int MAX_ELEVATION_FACTOR = 6; + + float getBaseElevation(); + + CardView getCardViewAt(int position); + + int getCount(); +} diff --git a/app/src/main/java/com/limefriends/molde/menu_map/reportCard/ReportCardItem.java b/app/src/main/java/com/limefriends/molde/menu_map/reportCard/ReportCardItem.java new file mode 100755 index 0000000..fc74ed0 --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/reportCard/ReportCardItem.java @@ -0,0 +1,21 @@ +package com.limefriends.molde.menu_map.reportCard; + + +public class ReportCardItem { + + private String text; + private String title; + + public ReportCardItem(String title, String text) { + this.title = title; + this.text = text; + } + + public String getText() { + return text; + } + + public String getTitle() { + return title; + } +} diff --git a/app/src/main/java/com/limefriends/molde/menu_map/reportCard/ReportCardPagerAdapter.java b/app/src/main/java/com/limefriends/molde/menu_map/reportCard/ReportCardPagerAdapter.java new file mode 100755 index 0000000..b8d1b8f --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/reportCard/ReportCardPagerAdapter.java @@ -0,0 +1,108 @@ +package com.limefriends.molde.menu_map.reportCard; + +import android.content.Context; +import android.support.v4.view.PagerAdapter; +import android.support.v7.widget.CardView; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; +import android.widget.Toast; + +import com.limefriends.molde.R; +import com.limefriends.molde.menu_map.MoldeMapFragment; +import com.limefriends.molde.menu_map.MoldeMapReportPagerAdapterCallback; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class ReportCardPagerAdapter extends PagerAdapter implements ReportCardAdapter { + private List reportCardViewList; + private List reportCardDataList; + private MoldeMapReportPagerAdapterCallback callback; + private float mBaseElevation; + private Context context; + + public ReportCardPagerAdapter(Context context) { + reportCardViewList = new ArrayList(); + reportCardDataList = new ArrayList(); + this.context = context; + } + + public void addCardItem(ReportCardItem item) { + reportCardViewList.add(null); + reportCardDataList.add(item); + } + + public void removeAllCardItem(){ + reportCardDataList.clear(); + } + + public float getBaseElevation() { + return mBaseElevation; + } + + @Override + public CardView getCardViewAt(int position) { + if(callback != null){ + callback.applyReportCardInfo(position); + } + return reportCardViewList.get(position); + } + + @Override + public int getCount() { + return reportCardDataList.size(); + } + + @Override + public boolean isViewFromObject(View view, Object object) { + return view == object; + } + + @Override + public Object instantiateItem(ViewGroup container, final int position) { + View view = LayoutInflater.from(container.getContext()) + .inflate(R.layout.map_report_card, container, false); + notifyDataSetChanged(); + container.addView(view); + bind(reportCardDataList.get(position), view); + CardView cardView = (CardView) view.findViewById(R.id.cardView); + cardView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Toast.makeText(context, position + 1 + "번째 컨테이너 눌림", Toast.LENGTH_SHORT).show(); + } + }); + if (mBaseElevation == 0) { + mBaseElevation = cardView.getCardElevation(); + } + cardView.setMaxCardElevation(mBaseElevation * MAX_ELEVATION_FACTOR); + reportCardViewList.set(position, cardView); + return view; + } + + @Override + public void destroyItem(ViewGroup container, int position, Object object) { + container.removeView((View) object); + reportCardViewList.set(position, null); + } + + private void bind(ReportCardItem item, View view) { + TextView titleTextView = (TextView) view.findViewById(R.id.titleTextView); + TextView contentTextView = (TextView) view.findViewById(R.id.contentTextView); + titleTextView.setText(item.getTitle()); + contentTextView.setText(item.getText()); + } + + public void setCallback(MoldeMapReportPagerAdapterCallback callback) { + this.callback = callback; + } + + @Override + public void notifyDataSetChanged() { + super.notifyDataSetChanged(); + } +} diff --git a/app/src/main/java/com/limefriends/molde/menu_map/reportCard/ShadowTransformer.java b/app/src/main/java/com/limefriends/molde/menu_map/reportCard/ShadowTransformer.java new file mode 100755 index 0000000..21aa27c --- /dev/null +++ b/app/src/main/java/com/limefriends/molde/menu_map/reportCard/ShadowTransformer.java @@ -0,0 +1,111 @@ +package com.limefriends.molde.menu_map.reportCard; + +import android.support.v4.view.ViewPager; +import android.support.v7.widget.CardView; +import android.util.Log; +import android.view.View; + + +public class ShadowTransformer implements ViewPager.OnPageChangeListener, ViewPager.PageTransformer { + + private ViewPager mViewPager; + private ReportCardAdapter mAdapter; + private float mLastOffset; + private boolean mScalingEnabled; + + public ShadowTransformer(ViewPager viewPager, ReportCardAdapter adapter) { + mViewPager = viewPager; + viewPager.addOnPageChangeListener(this); + mAdapter = adapter; + } + + public void enableScaling(boolean enable) { + if (mScalingEnabled && !enable) { + // shrink main card + CardView currentCard = mAdapter.getCardViewAt(mViewPager.getCurrentItem()); + if (currentCard != null) { + currentCard.animate().scaleY(1); + currentCard.animate().scaleX(1); + } + }else if(!mScalingEnabled && enable){ + // grow main card + CardView currentCard = mAdapter.getCardViewAt(mViewPager.getCurrentItem()); + if (currentCard != null) { + currentCard.animate().scaleY(1.1f); + currentCard.animate().scaleX(1.1f); + } + } + + mScalingEnabled = enable; + } + + @Override + public void transformPage(View page, float position) { + + } + + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + int realCurrentPosition; + int nextPosition; + float baseElevation = mAdapter.getBaseElevation(); + float realOffset; + boolean goingLeft = mLastOffset > positionOffset; + + // If we're going backwards, onPageScrolled receives the last position + // instead of the current one + if (goingLeft) { + realCurrentPosition = position + 1; + nextPosition = position; + realOffset = 1 - positionOffset; + } else { + nextPosition = position + 1; + realCurrentPosition = position; + realOffset = positionOffset; + } + + // Avoid crash on overscroll + if (nextPosition > mAdapter.getCount() - 1 + || realCurrentPosition > mAdapter.getCount() - 1) { + return; + } + + CardView currentCard = mAdapter.getCardViewAt(realCurrentPosition); + + // This might be null if a fragment is being used + // and the views weren't created yet + if (currentCard != null) { + if (mScalingEnabled) { + currentCard.setScaleX((float) (1 + 0.1 * (1 - realOffset))); + currentCard.setScaleY((float) (1 + 0.1 * (1 - realOffset))); + } + currentCard.setCardElevation((baseElevation + baseElevation + * (ReportCardAdapter.MAX_ELEVATION_FACTOR - 1) * (1 - realOffset))); + } + + CardView nextCard = mAdapter.getCardViewAt(nextPosition); + + // We might be scrolling fast enough so that the next (or previous) card + // was already destroyed or a fragment might not have been created yet + if (nextCard != null) { + if (mScalingEnabled) { + nextCard.setScaleX((float) (1 + 0.1 * (realOffset))); + nextCard.setScaleY((float) (1 + 0.1 * (realOffset))); + } + nextCard.setCardElevation((baseElevation + baseElevation + * (ReportCardAdapter.MAX_ELEVATION_FACTOR - 1) * (realOffset))); + } + + mLastOffset = positionOffset; + } + + @Override + public void onPageSelected(int position) { + + } + + @Override + public void onPageScrollStateChanged(int state) { + } + +} diff --git a/app/src/main/java/com/limefriends/molde/menu_mypage/MoldeMyPageFragment.java b/app/src/main/java/com/limefriends/molde/menu_mypage/MoldeMyPageFragment.java index e386224..3b0d664 100644 --- a/app/src/main/java/com/limefriends/molde/menu_mypage/MoldeMyPageFragment.java +++ b/app/src/main/java/com/limefriends/molde/menu_mypage/MoldeMyPageFragment.java @@ -1,15 +1,16 @@ package com.limefriends.molde.menu_mypage; +import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import com.limefriends.molde.MoldeMainActivity; import com.limefriends.molde.R; -import com.limefriends.molde.menu_map.MoldeMapFragment; -public class MoldeMyPageFragment extends Fragment { +public class MoldeMyPageFragment extends Fragment implements MoldeMainActivity.onKeyBackPressedListener{ public static MoldeMyPageFragment newInstance() { return new MoldeMyPageFragment(); @@ -18,8 +19,17 @@ public static MoldeMyPageFragment newInstance() { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_molde_mypage, container, false); + return inflater.inflate(R.layout.mypage_fragment, container, false); } + @Override + public void onAttach(Context context) { + super.onAttach(context); + ((MoldeMainActivity)context).setOnKeyBackPressedListener(this); + } + + @Override + public void onBackKey() { + } } diff --git a/app/src/main/java/com/limefriends/molde/menu_reportlist/MoldeReportListFragment.java b/app/src/main/java/com/limefriends/molde/menu_reportlist/MoldeReportListFragment.java index efbd06c..d25b8f1 100644 --- a/app/src/main/java/com/limefriends/molde/menu_reportlist/MoldeReportListFragment.java +++ b/app/src/main/java/com/limefriends/molde/menu_reportlist/MoldeReportListFragment.java @@ -1,14 +1,16 @@ package com.limefriends.molde.menu_reportlist; +import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import com.limefriends.molde.MoldeMainActivity; import com.limefriends.molde.R; -public class MoldeReportListFragment extends Fragment { +public class MoldeReportListFragment extends Fragment implements MoldeMainActivity.onKeyBackPressedListener{ public static MoldeReportListFragment newInstance() { return new MoldeReportListFragment(); @@ -17,7 +19,17 @@ public static MoldeReportListFragment newInstance() { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_molde_reportlist, container, false); + return inflater.inflate(R.layout.reportlist_fragment, container, false); + } + + @Override + public void onAttach(Context context) { + super.onAttach(context); + ((MoldeMainActivity)context).setOnKeyBackPressedListener(this); + } + + @Override + public void onBackKey() { } diff --git a/app/src/main/res/anim/scale_up.xml b/app/src/main/res/anim/scale_up.xml new file mode 100755 index 0000000..21100e3 --- /dev/null +++ b/app/src/main/res/anim/scale_up.xml @@ -0,0 +1,11 @@ + + diff --git a/app/src/main/res/anim/trans_to_down.xml b/app/src/main/res/anim/trans_to_down.xml new file mode 100755 index 0000000..a880440 --- /dev/null +++ b/app/src/main/res/anim/trans_to_down.xml @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/app/src/main/res/anim/trans_to_little_down.xml b/app/src/main/res/anim/trans_to_little_down.xml new file mode 100755 index 0000000..603e61f --- /dev/null +++ b/app/src/main/res/anim/trans_to_little_down.xml @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/app/src/main/res/anim/trans_to_little_up.xml b/app/src/main/res/anim/trans_to_little_up.xml new file mode 100755 index 0000000..401e2da --- /dev/null +++ b/app/src/main/res/anim/trans_to_little_up.xml @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/app/src/main/res/anim/trans_to_up.xml b/app/src/main/res/anim/trans_to_up.xml new file mode 100755 index 0000000..80dc2d9 --- /dev/null +++ b/app/src/main/res/anim/trans_to_up.xml @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/app/src/main/res/drawable/back_to_home.png b/app/src/main/res/drawable/back_to_home.png new file mode 100644 index 0000000..bc953b9 Binary files /dev/null and b/app/src/main/res/drawable/back_to_home.png differ diff --git a/app/src/main/res/drawable/frame.xml b/app/src/main/res/drawable/frame.xml new file mode 100644 index 0000000..4a193a6 --- /dev/null +++ b/app/src/main/res/drawable/frame.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/line.xml b/app/src/main/res/drawable/line.xml new file mode 100644 index 0000000..c73bd0e --- /dev/null +++ b/app/src/main/res/drawable/line.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/my_location_icon.png b/app/src/main/res/drawable/my_location_icon.png new file mode 100644 index 0000000..c71fc50 Binary files /dev/null and b/app/src/main/res/drawable/my_location_icon.png differ diff --git a/app/src/main/res/drawable/report_search_loc_button.png b/app/src/main/res/drawable/report_search_loc_button.png new file mode 100644 index 0000000..6c3160a Binary files /dev/null and b/app/src/main/res/drawable/report_search_loc_button.png differ diff --git a/app/src/main/res/drawable/star_off.png b/app/src/main/res/drawable/star_off.png new file mode 100644 index 0000000..f029c79 Binary files /dev/null and b/app/src/main/res/drawable/star_off.png differ diff --git a/app/src/main/res/drawable/star_on.png b/app/src/main/res/drawable/star_on.png new file mode 100644 index 0000000..e94cc7f Binary files /dev/null and b/app/src/main/res/drawable/star_on.png differ diff --git a/app/src/main/res/drawable/text_clear_button.png b/app/src/main/res/drawable/text_clear_button.png new file mode 100644 index 0000000..e797fdb Binary files /dev/null and b/app/src/main/res/drawable/text_clear_button.png differ diff --git a/app/src/main/res/layout/custom_toolbar.xml b/app/src/main/res/layout/custom_toolbar.xml new file mode 100644 index 0000000..3891040 --- /dev/null +++ b/app/src/main/res/layout/custom_toolbar.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_molde_map.xml b/app/src/main/res/layout/fragment_molde_map.xml deleted file mode 100644 index 5a48493..0000000 --- a/app/src/main/res/layout/fragment_molde_map.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/fragment_molde_magazine.xml b/app/src/main/res/layout/magazine_fragment.xml similarity index 100% rename from app/src/main/res/layout/fragment_molde_magazine.xml rename to app/src/main/res/layout/magazine_fragment.xml diff --git a/app/src/main/res/layout/map_activity_molde_report.xml b/app/src/main/res/layout/map_activity_molde_report.xml new file mode 100644 index 0000000..9953d6e --- /dev/null +++ b/app/src/main/res/layout/map_activity_molde_report.xml @@ -0,0 +1,213 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_molde_search_map_info.xml b/app/src/main/res/layout/map_activity_molde_search_info.xml similarity index 75% rename from app/src/main/res/layout/activity_molde_search_map_info.xml rename to app/src/main/res/layout/map_activity_molde_search_info.xml index 666fcac..3e5f38c 100644 --- a/app/src/main/res/layout/activity_molde_search_map_info.xml +++ b/app/src/main/res/layout/map_activity_molde_search_info.xml @@ -24,17 +24,27 @@ android:padding="12dp" android:scaleType="fitXY" android:src="@drawable/map_search_button" - android:background="@color/white"/> + android:background="@android:color/transparent"/> + android:theme="@style/LocalSearchInputStyle"/> + + @@ -54,6 +65,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white" + android:layout_marginTop="8dp" android:layout_marginLeft="8dp" android:layout_marginRight="8dp" android:layout_marginBottom="8dp"/> diff --git a/app/src/main/res/layout/map_fragment.xml b/app/src/main/res/layout/map_fragment.xml new file mode 100644 index 0000000..28794e7 --- /dev/null +++ b/app/src/main/res/layout/map_fragment.xml @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +