Skip to content

Commit

Permalink
Resolved #381 - Better Log system
Browse files Browse the repository at this point in the history
  • Loading branch information
davideas committed Jun 5, 2017
1 parent 512353f commit bee5ed3
Show file tree
Hide file tree
Showing 14 changed files with 554 additions and 350 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import android.support.v7.widget.helper.ItemTouchHelper;
import android.text.InputType;
import android.transition.Fade;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand All @@ -50,6 +49,8 @@
import eu.davidea.flexibleadapter.helpers.UndoHelper;
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
import eu.davidea.flexibleadapter.items.IFlexible;
import eu.davidea.flexibleadapter.utils.Log;
import eu.davidea.flexibleadapter.utils.Log.Level;
import eu.davidea.samples.flexibleadapter.dialogs.EditItemDialog;
import eu.davidea.samples.flexibleadapter.dialogs.MessageDialog;
import eu.davidea.samples.flexibleadapter.fragments.AbstractFragment;
Expand Down Expand Up @@ -112,8 +113,6 @@ public class MainActivity extends AppCompatActivity implements
NavigationView.OnNavigationItemSelectedListener,
OnFragmentInteractionListener {

public static final String TAG = MainActivity.class.getSimpleName();

/**
* Bundle key representing the Active Fragment
*/
Expand Down Expand Up @@ -170,8 +169,8 @@ protected void onCreate(Bundle savedInstanceState) {
}

setContentView(R.layout.activity_main);
Log.d(TAG, "onCreate");
FlexibleAdapter.enableLogs(true);
FlexibleAdapter.enableLogs(Level.DEBUG);
Log.v("onCreate");

// Initialize Toolbar, Drawer & FAB
initializeToolbar();
Expand All @@ -187,7 +186,7 @@ protected void onCreate(Bundle savedInstanceState) {

@Override
public void onSaveInstanceState(Bundle outState) {
Log.v(TAG, "onSaveInstanceState!");
Log.v("onSaveInstanceState!");
mAdapter.onSaveInstanceState(outState);
getSupportFragmentManager().putFragment(outState, STATE_ACTIVE_FRAGMENT, mFragment);
super.onSaveInstanceState(outState);
Expand Down Expand Up @@ -264,7 +263,7 @@ public void onRefresh() {
}

private void initializeToolbar() {
Log.d(TAG, "initializeToolbar as actionBar");
Log.d("initializeToolbar as actionBar");
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mHeaderView = (HeaderView) findViewById(R.id.toolbar_header_view);
mHeaderView.bindTo(getString(R.string.app_name), getString(R.string.overall));
Expand Down Expand Up @@ -446,7 +445,7 @@ private void showFab() {
@Override
public void initSearchView(final Menu menu) {
// Associate searchable configuration with the SearchView
Log.d(TAG, "onCreateOptionsMenu setup SearchView!");
Log.d("onCreateOptionsMenu setup SearchView!");
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
MenuItem searchItem = menu.findItem(R.id.action_search);
if (searchItem != null) {
Expand Down Expand Up @@ -482,7 +481,7 @@ public boolean onMenuItemActionCollapse(MenuItem item) {
@Override
public boolean onQueryTextChange(String newText) {
if (mAdapter.hasNewSearchText(newText)) {
Log.d(TAG, "onQueryTextChange newText: " + newText);
Log.d("onQueryTextChange newText: " + newText);
mAdapter.setSearchText(newText);

// Fill and Filter mItems with your custom list and automatically animate the changes
Expand All @@ -499,7 +498,7 @@ public boolean onQueryTextChange(String newText) {

@Override
public boolean onQueryTextSubmit(String query) {
Log.v(TAG, "onQueryTextSubmit called!");
Log.v("onQueryTextSubmit called!");
return onQueryTextChange(query);
}

Expand All @@ -509,12 +508,12 @@ public boolean onQueryTextSubmit(String query) {

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
Log.v(TAG, "onPrepareOptionsMenu called!");
Log.v("onPrepareOptionsMenu called!");

if (mSearchView != null) {
//Has searchText?
if (!mAdapter.hasSearchText()) {
Log.d(TAG, "onPrepareOptionsMenu Clearing SearchView!");
Log.d("onPrepareOptionsMenu Clearing SearchView!");
mSearchView.setIconified(true);// This also clears the text in SearchView widget
} else {
//Necessary after the restoreInstanceState
Expand Down Expand Up @@ -701,7 +700,7 @@ public boolean onItemClick(int position) {
// Action on elements are allowed if Mode is IDLE, otherwise selection has priority
if (mAdapter.getMode() != SelectableAdapter.MODE_IDLE && mActionModeHelper != null) {
boolean activate = mActionModeHelper.onClick(position);
Log.d(TAG, "Last activated position " + mActionModeHelper.getActivatedPosition());
Log.d("Last activated position %s", mActionModeHelper.getActivatedPosition());
return activate;
} else {
// Notify the active callbacks or implement a custom action onClick
Expand Down Expand Up @@ -749,8 +748,7 @@ public void onItemMove(int fromPosition, int toPosition) {

@Override
public void onItemSwipe(final int position, int direction) {
Log.i(TAG, "onItemSwipe position=" + position +
" direction=" + (direction == ItemTouchHelper.LEFT ? "LEFT" : "RIGHT"));
Log.i("onItemSwipe position=%s direction=%s", position, (direction == ItemTouchHelper.LEFT ? "LEFT" : "RIGHT"));

// Option 1 FULL_SWIPE: Direct action no Undo Action
// Do something based on direction when item has been swiped:
Expand Down Expand Up @@ -829,7 +827,7 @@ public void onPostAction() {
*/
@Override
public void onUpdateEmptyView(int size) {
Log.d(TAG, "onUpdateEmptyView size=" + size);
Log.d("onUpdateEmptyView size=%s", size);
FastScroller fastScroller = (FastScroller) findViewById(R.id.fast_scroller);
View emptyView = findViewById(R.id.empty_view);
TextView emptyText = (TextView) findViewById(R.id.empty_text);
Expand Down Expand Up @@ -891,12 +889,12 @@ public void onDeleteConfirmed(int action) {
case R.layout.recycler_sub_item:
SubItem subItem = (SubItem) adapterItem;
DatabaseService.getInstance().removeSubItem(mAdapter.getExpandableOfDeletedChild(subItem), subItem);
Log.d(TAG, "Confirm removed " + subItem);
Log.d("Confirm removed %s", subItem);
break;
case R.layout.recycler_simple_item:
case R.layout.recycler_expandable_item:
DatabaseService.getInstance().removeItem(adapterItem);
Log.d(TAG, "Confirm removed " + adapterItem);
Log.d("Confirm removed %s", adapterItem);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
Expand All @@ -47,6 +46,7 @@
import java.util.List;

import eu.davidea.flexibleadapter.R;
import eu.davidea.flexibleadapter.utils.Log;

import static java.lang.annotation.RetentionPolicy.SOURCE;

Expand All @@ -56,9 +56,9 @@
* @see <a href="https://github.com/AndroidDeveloperLB/LollipopContactsRecyclerViewFastScroller">
* github.com/AndroidDeveloperLB/LollipopContactsRecyclerViewFastScroller</a>
* @since Up to the date 23/01/2016
* <br/>23/01/2016 Added onFastScrollerStateChange in the listener
* <br/>10/03/2017 Added autoHide, bubblePosition, bubbleEnabled, ignoreTouchesOutsideHandle (thanks to @arpinca)
* <br/>22/04/2017 Added minimum scroll threshold
* <br>23/01/2016 Added onFastScrollerStateChange in the listener
* <br>10/03/2017 Added autoHide, bubblePosition, bubbleEnabled, ignoreTouchesOutsideHandle (thanks to @arpinca)
* <br>22/04/2017 Added minimum scroll threshold
*/
public class FastScroller extends FrameLayout {

Expand Down Expand Up @@ -205,7 +205,7 @@ protected void notifyScrollStateChange(boolean scrolling) {
}

/**
* Layout customization.<br/>
* Layout customization.<br>
* Color for Selected State is the bubbleAndHandleColor defined inside the Drawables.
*
* @param layoutResId Main layout of Fast Scroller
Expand All @@ -232,7 +232,7 @@ public void setViewsToUse(@LayoutRes int layoutResId, @IdRes int bubbleResId, @I
}

/**
* Layout customization<br/>
* Layout customization<br>
* Color for Selected State is also customized by the user.
*
* @param layoutResId Main layout of Fast Scroller
Expand Down Expand Up @@ -288,7 +288,7 @@ public void setBubbleAndHandleColor(@ColorInt int color) {
handle.setImageDrawable(stateListDrawable);
} catch (Exception e) {
// This should never happen in theory (Java Reflection Exception)
Log.e(FastScroller.class.getSimpleName(), "Exception while setting Bubble and Handle Color", e);
Log.wtf(e, "Exception while setting Bubble and Handle Color");
}
}
}
Expand Down
Loading

0 comments on commit bee5ed3

Please sign in to comment.