Skip to content

Commit

Permalink
optimizing memory
Browse files Browse the repository at this point in the history
  • Loading branch information
jangwonseo committed Oct 28, 2015
1 parent d532c9e commit 0238620
Show file tree
Hide file tree
Showing 16 changed files with 100 additions and 23 deletions.
39 changes: 39 additions & 0 deletions app/src/main/java/vivz/slidenerd/agriculture/RecycleUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package vivz.slidenerd.agriculture;

import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;

/**
* Created by seo on 2015-10-29.
*/
public class RecycleUtils {

private RecycleUtils(){};

public static void recursiveRecycle(View root) {
if (root == null)
return;
root.setBackgroundDrawable(null);
if (root instanceof ViewGroup) {
ViewGroup group = (ViewGroup)root;
int count = group.getChildCount();
for (int i = 0; i < count; i++) {
recursiveRecycle(group.getChildAt(i));
}

if (!(root instanceof AdapterView)) {
group.removeAllViews();
}

}

if (root instanceof ImageView) {
((ImageView)root).setImageDrawable(null);
}
root = null;

return;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_intro);
introHandler = new Handler();
introHandler.postDelayed(irun, 1000);//약 1.0초동안 인트로 화면
//haha
//branch test
//test 2
// test 3
//tset 4
setting = getSharedPreferences("setting", MODE_PRIVATE);
editor= setting.edit();

Expand All @@ -46,6 +41,8 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void run() {
Intent introIntent = new Intent(getApplicationContext(), HomeActivity.class);
//인트로화면처럼 다시 리로드 될리 없는 액티비티에서으 이동시 화면이 전환됨과 동시에 종료
introIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(introIntent);
finish();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class MyDiaryActivity extends ActionBarActivity {
TextView txtView;
Button video; // 리스트뷰에 있는 재생버튼
Button addItem; // 리스트뷰에 있는 관심있는 항목 추가 버튼
Button backButton;
Button backButton,menuButton;//뒤로가기버튼, 홈 버튼
TextView keys;
phpDown task;
String themeName;
Expand All @@ -58,13 +58,15 @@ protected void onCreate(Bundle savedInstanceState) {
//m_Adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
vilageList = (ListView) findViewById(R.id.vilageList);

//뒤로가기버튼, 홈버튼
backButton = (Button)findViewById(R.id.myDiary_backbutton);
backButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onBackPressed();
}
});
menuButton = (Button)findViewById(R.id.mydiary_movetohome_);


// ListView에 어댑터 연결
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public void onClick(View view) {
public void onClick(View view) {
Intent moveToHomeIntent = new Intent(getApplicationContext(), HomeActivity.class);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP );
startActivity(moveToHomeIntent);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ public void onClick(View view) {
menuButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent moveToHomeIntent = new Intent(getApplicationContext(), HomeActivity.class);
Intent moveToHomeIntent = new Intent(getApplicationContext(), HomeActivity.class);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP );
startActivity(moveToHomeIntent);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.widget.TextView;

import vivz.slidenerd.agriculture.R;
import vivz.slidenerd.agriculture.home.HomeActivity;

public class ListDetailActivity_ extends ActionBarActivity {
//폰트
Expand All @@ -20,6 +21,9 @@ public class ListDetailActivity_ extends ActionBarActivity {
//전화버튼,마이다이어리버튼,부대시설지도버튼
Button phoneCall, addMydiary, findMap;

//뒤로가기버튼, 홈버튼
Button menuButton,backButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -43,6 +47,25 @@ protected void onCreate(Bundle savedInstanceState) {
findMap = (Button)findViewById(R.id.findmap);
findMap.setOnClickListener(detailClickListener);

//홈버튼, 뒤로가기버튼
menuButton = (Button)findViewById(R.id.listdetail_menubutton);
menuButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent moveToHomeIntent = new Intent(getApplicationContext(), HomeActivity.class);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP );
startActivity(moveToHomeIntent);
}
});
backButton = (Button)findViewById(R.id.listdeail_backbutton);
backButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onBackPressed();
}
});


}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ public void onClick(View v) {
case R.id.mydiary_movetohome:
Intent moveToHomeIntent = new Intent(getApplicationContext(), HomeActivity.class);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP );
startActivity(moveToHomeIntent);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public void onClick(View view) {
public void onClick(View view) {
Intent moveToHomeIntent = new Intent(getApplicationContext(), HomeActivity.class);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP );
startActivity(moveToHomeIntent);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ protected void onCreate(Bundle savedInstanceState) {
menuButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent moveToHomeIntent = new Intent(getApplicationContext(), HomeActivity.class);
Intent moveToHomeIntent = new Intent(getApplicationContext(), HomeActivity.class);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP );
startActivity(moveToHomeIntent);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.ArrayList;

import vivz.slidenerd.agriculture.R;
import vivz.slidenerd.agriculture.RecycleUtils;
import vivz.slidenerd.agriculture.home.HomeActivity;

public class NavigateSearch extends Activity {
Expand Down Expand Up @@ -69,7 +70,7 @@ protected void onCreate(Bundle savedInstanceState) {
backButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onBackPressed();
finish();
}
});

Expand All @@ -79,6 +80,7 @@ public void onClick(View view) {
public void onClick(View view) {
Intent moveToHomeIntent = new Intent(getApplicationContext(), HomeActivity.class);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP );
startActivity(moveToHomeIntent);
}
});
Expand Down Expand Up @@ -195,8 +197,21 @@ public void listRead(ArrayList<TMapPOIItem> poiItem){
}

@Override
public void onBackPressed() {
super.onBackPressed();
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch(keyCode){
case KeyEvent.KEYCODE_BACK:
finish();
return true;
}
return super.onKeyDown(keyCode, event);
}

@Override
protected void onDestroy() {
RecycleUtils.recursiveRecycle(getWindow().getDecorView());
System.gc();

super.onDestroy();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ public void onClick(View v) {
case R.id.recruit_menubutton:
Intent moveToHomeIntent = new Intent(getApplicationContext(), HomeActivity.class);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP );
startActivity(moveToHomeIntent);
break;
case R.id.regist_button: // 등록 버튼
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,20 @@
import android.graphics.Typeface;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import org.w3c.dom.Text;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Calendar;

import vivz.slidenerd.agriculture.R;
import vivz.slidenerd.agriculture.service_prepare;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ public void onClick(View view) {
menuButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent moveToHomeIntent = new Intent(getApplicationContext(), HomeActivity.class);
Intent moveToHomeIntent = new Intent(getApplicationContext(), HomeActivity.class);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP );
startActivity(moveToHomeIntent);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ public void onClick(View view) {
menuButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent moveToHomeIntent = new Intent(getApplicationContext(), HomeActivity.class);
Intent moveToHomeIntent = new Intent(getApplicationContext(), HomeActivity.class);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
moveToHomeIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP );
startActivity(moveToHomeIntent);
}
});
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_listdetail_.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
android:clickable="false"
android:focusable="false">
<Button
android:id="@+id/listDeail_backbutton"
android:id="@+id/listdeail_backbutton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/btn_pressback"/>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_my_diary.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
>

<Button
android:id="@+id/mydiary_movetohome_"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/btn_movetohome"/>
Expand Down

0 comments on commit 0238620

Please sign in to comment.