soonmyeong2

검색창 디자인 및 앱 종료 최적화

......@@ -34,7 +34,7 @@ dependencies {
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0-beta05'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.firebase:firebase-analytics:17.2.0'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
......
......@@ -23,7 +23,7 @@
<activity android:name=".SignInActivity" />
<activity android:name=".SignUpActivity" />
<activity android:name=".MainActivity" />
<activity android:name=".SearchActivity" />
<activity android:name=".SearchActivity" android:windowSoftInputMode="adjustNothing"/>
<activity
android:name=".SplashActivity"
android:theme="@style/SplashTheme">
......
......@@ -28,7 +28,6 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
//onboarding start
//onboarding end
setContentView(R.layout.activity_main)
......
package com.example.vip
import android.content.Context
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
//import androidx.appcompat.widget.SearchView
import android.widget.SearchView
import android.widget.Toast
import androidx.core.app.ComponentActivity.ExtraData
import androidx.core.content.ContextCompat.getSystemService
import android.icu.lang.UCharacter.GraphemeClusterBreak.T
import android.view.View
import android.widget.Button
import android.content.Intent
import android.util.Log
import android.view.inputmethod.InputMethodManager
import android.widget.*
import androidx.core.content.ContextCompat
import com.google.firebase.database.*
import com.google.firebase.database.DatabaseReference
......@@ -35,21 +35,43 @@ class SearchActivity : AppCompatActivity() {
setContentView(R.layout.search)
val searchList = ArrayList<SearchItem>()
val no_search : ImageView = findViewById(R.id.no_matching) // 노서치이미지
val searchView: SearchView
searchView = findViewById(R.id.searchForm)
//searchView.onActionViewExpanded(); //new Added line
searchView.setIconifiedByDefault(false)
fun CloseKeyboard()
{
var view = this.currentFocus
if(view != null)
{
val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
}
}
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String): Boolean {
// 검색 버튼이 눌러졌을 때 이벤트 처리
val layout : LinearLayout = findViewById(R.id.hashtag_linear)
layout.setVisibility(View.GONE)
CloseKeyboard()
database.orderByChild("Policy").startAt("$query").endAt("$query"+"\uf8ff").addListenerForSingleValueEvent(object : ValueEventListener {
override fun onCancelled(p0: DatabaseError) {
Toast.makeText(this@SearchActivity, "실패부분 : $query", Toast.LENGTH_SHORT).show()
}
override fun onDataChange(dataSnapshot: DataSnapshot) {
if (dataSnapshot.exists() == false){ // 값 없을 때
no_search.setVisibility(View.VISIBLE)
}
else {
no_search.setVisibility(View.GONE)
}
for (memoSnapshot in dataSnapshot.children){
val memo = memoSnapshot.getValue(MemoItem::class.java)
......
......@@ -4,6 +4,7 @@ import android.content.Intent
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.app.ActionBar
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
......@@ -90,6 +91,20 @@ class SignInActivity : AppCompatActivity() {
return true
}
var back_pressed: Long = 0 // 뒤로가기 종료
override fun onBackPressed() {
if (back_pressed + 2000 > System.currentTimeMillis()) {
finishAffinity()
System.runFinalization()
System.exit(0)
}
//super.onBackPressed()
else
Toast.makeText(getBaseContext(), "\'뒤로\' 버튼을 한번 더 누르시면 종료됩니다.", Toast.LENGTH_SHORT).show()
back_pressed = System.currentTimeMillis()
}
// 4.툴바 메뉴 버튼이 클릭 됐을 때 콜백
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
// 클릭된 메뉴 아이템의 아이디 마다 when 구절로 클릭시 동작을 설정한다.
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="@android:color/transparent" />
<stroke
android:width="3dp"
android:color="#C029ABE2" />
<corners android:radius="30dp"/>
<!--<padding
android:top="8dp"/>-->
</shape>
\ No newline at end of file
This diff is collapsed. Click to expand it.