forked from organicmaps/organicmaps
Fixes after Dmity's comments.
This commit is contained in:
parent
27e542570b
commit
7553ecead1
2 changed files with 71 additions and 54 deletions
|
@ -27,8 +27,6 @@ import android.text.Spanned;
|
|||
import android.text.TextUtils;
|
||||
import android.text.style.AbsoluteSizeSpan;
|
||||
import android.util.Log;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
@ -42,7 +40,6 @@ import android.widget.ProgressBar;
|
|||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.app.ActivityManager;
|
||||
|
||||
import com.mapswithme.country.ActiveCountryTree;
|
||||
import com.mapswithme.country.DownloadActivity;
|
||||
|
@ -83,12 +80,12 @@ import com.mapswithme.util.ShareAction;
|
|||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.Utils;
|
||||
import com.mapswithme.util.Yota;
|
||||
import com.mapswithme.util.log.MemLogging;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
import com.nineoldandroids.animation.Animator;
|
||||
import com.nineoldandroids.animation.ObjectAnimator;
|
||||
import com.nineoldandroids.view.ViewHelper;
|
||||
import com.nvidia.devtech.NvEventQueueActivity;
|
||||
import com.mapswithme.maps.BuildConfig;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
@ -166,9 +163,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
private LocationPredictor mLocationPredictor;
|
||||
private LikesManager mLikesManager;
|
||||
|
||||
private Timer timer;
|
||||
private TimerTask timerTask;
|
||||
|
||||
private MemLogging mMemLogging;
|
||||
|
||||
public static Intent createShowMapIntent(Context context, Index index, boolean doAutoDownload)
|
||||
{
|
||||
|
@ -718,6 +713,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
|
||||
mLocationPredictor = new LocationPredictor(new Handler(), this);
|
||||
mLikesManager = new LikesManager(this);
|
||||
mMemLogging = new MemLogging(this);
|
||||
}
|
||||
|
||||
private void initViews()
|
||||
|
@ -1134,13 +1130,14 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
mLocationPredictor.resume();
|
||||
mLikesManager.showLikeDialogs();
|
||||
|
||||
startTimer();
|
||||
mMemLogging.startLogging();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause()
|
||||
{
|
||||
stopTimer();
|
||||
mMemLogging.stopLogging();
|
||||
|
||||
pauseLocation();
|
||||
stopWatchingExternalStorage();
|
||||
stopWatchingCompassStatusUpdate();
|
||||
|
@ -1782,49 +1779,4 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void startTimer()
|
||||
{
|
||||
if (BuildConfig.DEBUG == true)
|
||||
{
|
||||
timer = new Timer();
|
||||
initTimerTask();
|
||||
timer.schedule(timerTask, 0, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopTimer()
|
||||
{
|
||||
if (BuildConfig.DEBUG == true)
|
||||
{
|
||||
if (timer != null)
|
||||
{
|
||||
timer.cancel();
|
||||
timer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void initTimerTask()
|
||||
{
|
||||
timerTask = new TimerTask()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
final Debug.MemoryInfo debugMI = new Debug.MemoryInfo();
|
||||
Debug.getMemoryInfo(debugMI);
|
||||
final ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
|
||||
final ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
|
||||
activityManager.getMemoryInfo(mi);
|
||||
Log.d(TAG, "Memory info: Debug.getNativeHeapSize() = " + Debug.getNativeHeapSize() / 1024 +
|
||||
"KB; Debug.getNativeHeapAllocatedSize() = " + Debug.getNativeHeapAllocatedSize() / 1024 +
|
||||
"KB, Debug.getNativeHeapFreeSize() = " + Debug.getNativeHeapFreeSize() / 1024 +
|
||||
"KB. debugMI.getTotalPrivateDirty() = " + debugMI.getTotalPrivateDirty() +
|
||||
"KB. debugMI.getTotalPss() = " + debugMI.getTotalPss() +
|
||||
"KB. mi.availMem = " + mi.availMem / 1024 +
|
||||
"KB. mi.threshold = " + mi.threshold / 1024 +
|
||||
"KB. mi.lowMemory = " + mi.lowMemory);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
65
android/src/com/mapswithme/util/log/MemLogging.java
Normal file
65
android/src/com/mapswithme/util/log/MemLogging.java
Normal file
|
@ -0,0 +1,65 @@
|
|||
package com.mapswithme.util.log;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.os.Debug;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import com.mapswithme.maps.BuildConfig;
|
||||
import android.os.Build;
|
||||
|
||||
|
||||
public class MemLogging
|
||||
{
|
||||
private final static String TAG = "MemLogging";
|
||||
private Context mContext;
|
||||
private Handler mHandler;
|
||||
|
||||
private Runnable logging = new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final Debug.MemoryInfo debugMI = new Debug.MemoryInfo();
|
||||
Debug.getMemoryInfo(debugMI);
|
||||
final ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
|
||||
final ActivityManager activityManager =
|
||||
(ActivityManager) mContext.getSystemService(mContext.ACTIVITY_SERVICE);
|
||||
activityManager.getMemoryInfo(mi);
|
||||
StringBuilder log = new StringBuilder("Memory info: Debug.getNativeHeapSize() = " + Debug.getNativeHeapSize() / 1024 +
|
||||
"KB; Debug.getNativeHeapAllocatedSize() = " + Debug.getNativeHeapAllocatedSize() / 1024 +
|
||||
"KB, Debug.getNativeHeapFreeSize() = " + Debug.getNativeHeapFreeSize() / 1024 +
|
||||
"KB. debugMI.getTotalPrivateDirty() = " + debugMI.getTotalPrivateDirty() +
|
||||
"KB. debugMI.getTotalPss() = " + debugMI.getTotalPss() +
|
||||
"KB. mi.availMem = " + mi.availMem / 1024 +
|
||||
"KB. mi.threshold = " + mi.threshold / 1024 +
|
||||
"KB. mi.lowMemory = " + mi.lowMemory + " ");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
|
||||
{
|
||||
log.append("mi.totalMem = " + mi.totalMem / 1024 + "KB.");
|
||||
}
|
||||
Log.d(TAG, log.toString());
|
||||
|
||||
final long memLogPeriod = 3000;
|
||||
mHandler.postDelayed(logging, memLogPeriod);
|
||||
}
|
||||
};
|
||||
|
||||
public MemLogging(Context context)
|
||||
{
|
||||
mContext = context;
|
||||
mHandler = new Handler();
|
||||
}
|
||||
|
||||
public void startLogging()
|
||||
{
|
||||
if (BuildConfig.DEBUG)
|
||||
mHandler.post(logging);
|
||||
}
|
||||
|
||||
public void stopLogging()
|
||||
{
|
||||
if (BuildConfig.DEBUG)
|
||||
mHandler.removeCallbacks(logging);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue