Java Code Examples for android.util.Log

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project ActionBarSherlock, under directory /library/src/android/support/v4/app/.

Source file: Watson.java

  17 
vote

@Override public boolean onMenuItemSelected(int featureId,MenuItem item){
  if (DEBUG)   Log.d(TAG,"[onMenuItemSelected] featureId: " + featureId + ", item: "+ item);
  if (featureId == Window.FEATURE_OPTIONS_PANEL) {
    if (onOptionsItemSelected(item)) {
      return true;
    }
    if (mFragments.mAdded != null) {
      for (int i=0; i < mFragments.mAdded.size(); i++) {
        Fragment f=mFragments.mAdded.get(i);
        if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnOptionsItemSelectedListener) {
          if (((OnOptionsItemSelectedListener)f).onOptionsItemSelected(item)) {
            return true;
          }
        }
      }
    }
  }
  return false;
}
 

Example 2

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/android/support/v4/app/.

Source file: _ActionBarSherlockTrojanHorse.java

  15 
vote

@Override public boolean onCreatePanelMenu(int featureId,Menu menu){
  if (DEBUG)   Log.d(TAG,"[onCreatePanelMenu] featureId: " + featureId + ", menu: "+ menu);
  if (featureId == Window.FEATURE_OPTIONS_PANEL) {
    boolean result=onCreateOptionsMenu(menu);
    if (DEBUG)     Log.d(TAG,"[onCreatePanelMenu] activity create result: " + result);
    MenuInflater inflater=getSupportMenuInflater();
    boolean show=false;
    ArrayList<Fragment> newMenus=null;
    if (mFragments.mActive != null) {
      for (int i=0; i < mFragments.mAdded.size(); i++) {
        Fragment f=mFragments.mAdded.get(i);
        if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnCreateOptionsMenuListener) {
          show=true;
          ((OnCreateOptionsMenuListener)f).onCreateOptionsMenu(menu,inflater);
          if (newMenus == null) {
            newMenus=new ArrayList<Fragment>();
          }
          newMenus.add(f);
        }
      }
    }
    if (mCreatedMenus != null) {
      for (int i=0; i < mCreatedMenus.size(); i++) {
        Fragment f=mCreatedMenus.get(i);
        if (newMenus == null || !newMenus.contains(f)) {
          f.onDestroyOptionsMenu();
        }
      }
    }
    mCreatedMenus=newMenus;
    if (DEBUG)     Log.d(TAG,"[onCreatePanelMenu] fragments create result: " + show);
    result|=show;
    if (DEBUG)     Log.d(TAG,"[onCreatePanelMenu] returning " + result);
    return result;
  }
  return false;
}
 

Example 3

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/android/support/v4/app/.

Source file: _ActionBarSherlockTrojanHorse.java

  15 
vote

@Override public boolean onPreparePanel(int featureId,View view,Menu menu){
  if (DEBUG)   Log.d(TAG,"[onPreparePanel] featureId: " + featureId + ", view: "+ view+ " menu: "+ menu);
  if (featureId == Window.FEATURE_OPTIONS_PANEL) {
    boolean result=onPrepareOptionsMenu(menu);
    if (DEBUG)     Log.d(TAG,"[onPreparePanel] activity prepare result: " + result);
    boolean show=false;
    if (mFragments.mActive != null) {
      for (int i=0; i < mFragments.mAdded.size(); i++) {
        Fragment f=mFragments.mAdded.get(i);
        if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnPrepareOptionsMenuListener) {
          show=true;
          ((OnPrepareOptionsMenuListener)f).onPrepareOptionsMenu(menu);
        }
      }
    }
    if (DEBUG)     Log.d(TAG,"[onPreparePanel] fragments prepare result: " + show);
    result|=show;
    result&=menu.hasVisibleItems();
    if (DEBUG)     Log.d(TAG,"[onPreparePanel] returning " + result);
    return result;
  }
  return false;
}
 

Example 4

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/android/support/v4/app/.

Source file: _ActionBarSherlockTrojanHorse.java

  15 
vote

@Override public boolean onMenuItemSelected(int featureId,MenuItem item){
  if (DEBUG)   Log.d(TAG,"[onMenuItemSelected] featureId: " + featureId + ", item: "+ item);
  if (featureId == Window.FEATURE_OPTIONS_PANEL) {
    if (onOptionsItemSelected(item)) {
      return true;
    }
    if (mFragments.mActive != null) {
      for (int i=0; i < mFragments.mAdded.size(); i++) {
        Fragment f=mFragments.mAdded.get(i);
        if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnOptionsItemSelectedListener) {
          if (((OnOptionsItemSelectedListener)f).onOptionsItemSelected(item)) {
            return true;
          }
        }
      }
    }
  }
  return false;
}
 

Example 5

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/.

Source file: ActionBarSherlock.java

  15 
vote

/** 
 * Register an ActionBarSherlock implementation.
 * @param implementationClass Target implementation class which extends{@link ActionBarSherlock}. This class must also be annotated with {@link Implementation}.
 */
public static void registerImplementation(Class<? extends ActionBarSherlock> implementationClass){
  if (!implementationClass.isAnnotationPresent(Implementation.class)) {
    throw new IllegalArgumentException("Class " + implementationClass.getSimpleName() + " is not annotated with @Implementation");
  }
 else   if (IMPLEMENTATIONS.containsValue(implementationClass)) {
    if (DEBUG)     Log.w(TAG,"Class " + implementationClass.getSimpleName() + " already registered");
    return;
  }
  Implementation impl=implementationClass.getAnnotation(Implementation.class);
  if (DEBUG)   Log.i(TAG,"Registering " + implementationClass.getSimpleName() + " with qualifier "+ impl);
  IMPLEMENTATIONS.put(impl,implementationClass);
}
 

Example 6

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/.

Source file: ActionBarSherlock.java

  15 
vote

/** 
 * Internal method to trigger the menu creation process.
 * @return {@code true} if menu creation should proceed.
 */
protected final boolean callbackCreateOptionsMenu(Menu menu){
  if (DEBUG)   Log.d(TAG,"[callbackCreateOptionsMenu] menu: " + menu);
  boolean result=true;
  if (mActivity instanceof OnCreatePanelMenuListener) {
    OnCreatePanelMenuListener listener=(OnCreatePanelMenuListener)mActivity;
    result=listener.onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL,menu);
  }
 else   if (mActivity instanceof OnCreateOptionsMenuListener) {
    OnCreateOptionsMenuListener listener=(OnCreateOptionsMenuListener)mActivity;
    result=listener.onCreateOptionsMenu(menu);
  }
  if (DEBUG)   Log.d(TAG,"[callbackCreateOptionsMenu] returning " + result);
  return result;
}
 

Example 7

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/.

Source file: ActionBarSherlock.java

  15 
vote

/** 
 * Internal method to trigger the menu preparation process.
 * @return {@code true} if menu preparation should proceed.
 */
protected final boolean callbackPrepareOptionsMenu(Menu menu){
  if (DEBUG)   Log.d(TAG,"[callbackPrepareOptionsMenu] menu: " + menu);
  boolean result=true;
  if (mActivity instanceof OnPreparePanelListener) {
    OnPreparePanelListener listener=(OnPreparePanelListener)mActivity;
    result=listener.onPreparePanel(Window.FEATURE_OPTIONS_PANEL,null,menu);
  }
 else   if (mActivity instanceof OnPrepareOptionsMenuListener) {
    OnPrepareOptionsMenuListener listener=(OnPrepareOptionsMenuListener)mActivity;
    result=listener.onPrepareOptionsMenu(menu);
  }
  if (DEBUG)   Log.d(TAG,"[callbackPrepareOptionsMenu] returning " + result);
  return result;
}
 

Example 8

From project abalone-android, under directory /src/com/bytopia/abalone/.

Source file: BoardRenderer.java

  15 
vote

/** 
 * Notifies the renderer that the board was updated.
 * @param b board that was updated
 */
public void updateBoard(Board b){
  this.board=b;
  Log.d("update","BoardDrawer.UpdateBoard at " + System.nanoTime());
  balls=new ArrayList<RenderBall>();
  for (int i=1; i <= 9; i++) {
    float shift=(5f - i) * ballSize / 2f;
    float x, y;
    for (int j=1; j <= 9; j++) {
      int state=b.getState(i,j);
      if (state != Layout.N) {
        x=borderSize + shift + (j - 1) * ballSize + ballSize / 2f;
        y=(float)(borderSize + (i - 1) * ballSize * SQRT3_2) + ballSize / 2f;
        balls.add(new RenderBall(x,y,state));
      }
    }
  }
  if (animBalls != null) {
    animBalls=null;
  }
  if (emptyBalls != null) {
    emptyBalls=null;
  }
  animation=false;
  view.postInvalidate();
}
 

Example 9

From project abalone-android, under directory /src/com/bytopia/abalone/.

Source file: BoardRenderer.java

  15 
vote

/** 
 * Updates sizes according to the given board diameter.
 * @param boardDiameter distance between two opposite corners of the board
 */
public void rescale(int boardDiameter,int size){
  Log.d("rescale","Rescaling the board");
  boardRect=new RectF(boardDiameter / 4f - 1,1,3f * boardDiameter / 4f + 1,boardDiameter / 2);
  balls=new ArrayList<RenderBall>();
  ballSize=((float)size - 2 * borderSize) / 9f;
  view.postInvalidate();
}
 

Example 10

From project abalone-android, under directory /src/com/bytopia/abalone/.

Source file: BoardView.java

  15 
vote

private int measure(int measureSpec){
  int result=0;
  int specMode=MeasureSpec.getMode(measureSpec);
  int specSize=MeasureSpec.getSize(measureSpec);
  if (specMode == MeasureSpec.UNSPECIFIED) {
    result=200;
  }
 else {
    result=specSize;
  }
  Log.d("screen","result=" + result);
  return result;
}
 

Example 11

From project Absolute-Android-RSS, under directory /src/com/AA/Other/.

Source file: RSSParse.java

  15 
vote

/** 
 * Get the list of articles currently contained in the RSS feed.
 * @param isBackground if the request is being run in the background
 * @param callingContext current application context
 * @return List of articles contained in the RSS on success. On failure returns null
 */
public static List<Article> getArticles(boolean isBackground,Context callingContext){
  if (!isNetworkAvailable(isBackground,callingContext))   return null;
  Document doc=getDocument();
  if (doc == null)   return null;
  try {
    ArrayList<Article> articles=new ArrayList<Article>();
    NodeList items=doc.getElementsByTagName("item");
    for (int i=0; i < items.getLength(); i++) {
      Element el=(Element)items.item(i);
      String title=el.getElementsByTagName("title").item(0).getFirstChild().getNodeValue();
      String date=el.getElementsByTagName("pubDate").item(0).getFirstChild().getNodeValue();
      String url=el.getElementsByTagName("link").item(0).getFirstChild().getNodeValue();
      String desc=el.getElementsByTagName("description").item(0).getFirstChild().getNodeValue();
      articles.add(new Article(desc,title,date,url));
    }
    return articles;
  }
 catch (  Exception e) {
    Log.e("AARSS","Error Parsing RSS",e);
    return null;
  }
}
 

Example 12

From project Absolute-Android-RSS, under directory /src/com/AA/Other/.

Source file: RSSParse.java

  15 
vote

/** 
 * Get the XML document for the RSS feed
 * @return the XML Document for the feed on success, on error returns null
 */
private static Document getDocument(){
  Document doc=null;
  try {
    DocumentBuilder builder=DocumentBuilderFactory.newInstance().newDocumentBuilder();
    DefaultHttpClient client=new DefaultHttpClient();
    HttpGet request=new HttpGet(URI);
    HttpResponse response=client.execute(request);
    doc=builder.parse(response.getEntity().getContent());
  }
 catch (  java.io.IOException e) {
    return null;
  }
catch (  SAXException e) {
    Log.e("AARSS","Parse Exception in RSS feed",e);
    return null;
  }
catch (  Exception e) {
    return null;
  }
  return doc;
}
 

Example 13

From project Absolute-Android-RSS, under directory /src/com/AA/Services/.

Source file: RssService.java

  15 
vote

/** 
 * Writes the received data to the application settings so that data restoration is easier
 * @param articleList - List of all the articles that have been aggregated from the stream
 */
public static void writeData(Context context,List<Article> articleList){
  try {
    FileOutputStream fileStream=context.openFileOutput("articles",Context.MODE_PRIVATE);
    ObjectOutputStream writer=new ObjectOutputStream(fileStream);
    writer.writeObject(articleList);
    writer.close();
    fileStream.close();
  }
 catch (  IOException e) {
    Log.e("AARSS","Problem saving file.",e);
    return;
  }
}
 

Example 14

From project actionbar, under directory /actionbar-example/src/main/java/com/github/erd/actionbar/widget/.

Source file: ActionbarExample1.java

  15 
vote

/** 
 * {@inheritDoc}
 */
@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  setContentView(R.layout.activity_actionbar_1);
  Actionbar actionbar=(Actionbar)findViewById(R.id.action_bar);
  actionbar.setOnHomeClickListener(new Actionbar.OnHomeClickListener(){
    @Override public void onHomeClicked(    View view,    int icon){
      Log.v("Actionbar","Home button clicked...");
    }
  }
);
}
 

Example 15

From project actionbar, under directory /actionbar-example/src/main/java/com/github/erd/actionbar/widget/.

Source file: ActionbarExample2.java

  15 
vote

/** 
 * {@inheritDoc}
 */
@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  setContentView(R.layout.activity_actionbar_2);
  Actionbar actionbar=(Actionbar)findViewById(R.id.action_bar);
  actionbar.addActionButton(ActionbarButton.ICON_PHOTO);
  actionbar.addActionButton(ActionbarButton.ICON_SHARE);
  actionbar.setOnHomeClickListener(new Actionbar.OnHomeClickListener(){
    @Override public void onHomeClicked(    View view,    int icon){
      Log.d("Actionbar","Home button clicked");
    }
  }
);
  actionbar.setOnItemClickListener(new Actionbar.OnItemClickListener(){
    @Override public void onItemClicked(    View view,    int icon){
      Log.d("Actionbar","Button clicked: " + icon);
    }
  }
);
}
 

Example 16

From project actionbar, under directory /actionbar-example/src/main/java/com/github/erd/actionbar/widget/.

Source file: ActionbarExample3.java

  15 
vote

/** 
 * {@inheritDoc}
 */
@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  setContentView(R.layout.activity_actionbar_3);
  final Actionbar actionbar=(Actionbar)findViewById(R.id.action_bar);
  actionbar.addActionButton(ActionbarButton.ICON_PHOTO);
  actionbar.addActionButton(ActionbarButton.ICON_SHARE);
  actionbar.setOnHomeClickListener(new Actionbar.OnHomeClickListener(){
    @Override public void onHomeClicked(    View view,    int icon){
      Log.d("Actionbar","Home button clicked");
    }
  }
);
  actionbar.setOnItemClickListener(new Actionbar.OnItemClickListener(){
    @Override public void onItemClicked(    View view,    int icon){
      Log.d("Actionbar","Button clicked: " + icon);
    }
  }
);
  Button show=(Button)findViewById(R.id.show);
  show.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      actionbar.showProgressBar();
    }
  }
);
  Button hide=(Button)findViewById(R.id.hide);
  hide.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      actionbar.hideProgressBar();
    }
  }
);
}
 

Example 17

From project ActionBarCompat, under directory /ActionBarCompat/src/sk/m217/actionbarcompat/.

Source file: ActionBarHelperBase.java

  15 
vote

/** 
 * Sets up the compatibility action bar with the given title.
 */
private void setupActionBar(){
  final ViewGroup actionBarCompat=getActionBarCompat();
  if (actionBarCompat == null) {
    return;
  }
  mHomeItem=new SimpleMenuItem(new SimpleMenu(mActivity),android.R.id.home,0,mActivity.getTitle());
  final LayoutInflater inflater=LayoutInflater.from(mActivity);
  mHomeLayout=(HomeView)inflater.inflate(R.layout.actionbar_compat_home,actionBarCompat,false);
  mHomeLayout.setOnClickListener(mUpClickListener);
  mHomeLayout.setClickable(true);
  mHomeLayout.setFocusable(true);
  mExpandedHomeLayout=(HomeView)inflater.inflate(R.layout.actionbar_compat_home,actionBarCompat,false);
  mExpandedHomeLayout.setUp(true);
  mExpandedHomeLayout.setOnClickListener(mExpandedActionViewUpListener);
  mExpandedHomeLayout.setContentDescription(mActivity.getResources().getText(R.string.action_bar_up_description));
  mExpandedHomeLayout.setFocusable(true);
  ApplicationInfo appInfo=mActivity.getApplicationInfo();
  PackageManager pm=mActivity.getPackageManager();
  try {
    mIcon=pm.getActivityIcon(mActivity.getComponentName());
  }
 catch (  NameNotFoundException e) {
    Log.e(TAG,"Activity component name not found!",e);
  }
  if (mIcon == null) {
    mIcon=appInfo.loadIcon(pm);
  }
  mHomeLayout.setIcon(mIcon);
  actionBarCompat.addView(mHomeLayout);
  LinearLayout.LayoutParams springLayoutParams=new LinearLayout.LayoutParams(0,ViewGroup.LayoutParams.FILL_PARENT);
  springLayoutParams.weight=1;
  mTitle=mActivity.getTitle();
  mTitleText=new TextView(mActivity,null,R.attr.actionbarCompatTitleStyle);
  mTitleText.setLayoutParams(springLayoutParams);
  mTitleText.setText(mTitle);
  actionBarCompat.addView(mTitleText);
  setDisplayOptions(DISPLAY_SHOW_HOME | DISPLAY_SHOW_TITLE);
}
 

Example 18

From project ActionBarCompat, under directory /ActionBarCompat/src/sk/m217/actionbarcompat/.

Source file: SimpleMenuItem.java

  15 
vote

public boolean invoke(){
  if (mClickListener != null && mClickListener.onMenuItemClick(this)) {
    return true;
  }
  if (mMenu.dispatchMenuItemSelected(mMenu,this)) {
    return true;
  }
  if (mIntent != null) {
    try {
      mMenu.getContext().startActivity(mIntent);
      return true;
    }
 catch (    ActivityNotFoundException e) {
      Log.e(TAG,"Can't find activity to handle intent; ignoring",e);
    }
  }
  return false;
}
 

Example 19

From project ActionBarSherlock, under directory /library/src/android/support/v4/app/.

Source file: Watson.java

  15 
vote

@Override public boolean onCreatePanelMenu(int featureId,Menu menu){
  if (DEBUG)   Log.d(TAG,"[onCreatePanelMenu] featureId: " + featureId + ", menu: "+ menu);
  if (featureId == Window.FEATURE_OPTIONS_PANEL) {
    boolean result=onCreateOptionsMenu(menu);
    if (DEBUG)     Log.d(TAG,"[onCreatePanelMenu] activity create result: " + result);
    MenuInflater inflater=getSupportMenuInflater();
    boolean show=false;
    ArrayList<Fragment> newMenus=null;
    if (mFragments.mAdded != null) {
      for (int i=0; i < mFragments.mAdded.size(); i++) {
        Fragment f=mFragments.mAdded.get(i);
        if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnCreateOptionsMenuListener) {
          show=true;
          ((OnCreateOptionsMenuListener)f).onCreateOptionsMenu(menu,inflater);
          if (newMenus == null) {
            newMenus=new ArrayList<Fragment>();
          }
          newMenus.add(f);
        }
      }
    }
    if (mCreatedMenus != null) {
      for (int i=0; i < mCreatedMenus.size(); i++) {
        Fragment f=mCreatedMenus.get(i);
        if (newMenus == null || !newMenus.contains(f)) {
          f.onDestroyOptionsMenu();
        }
      }
    }
    mCreatedMenus=newMenus;
    if (DEBUG)     Log.d(TAG,"[onCreatePanelMenu] fragments create result: " + show);
    result|=show;
    if (DEBUG)     Log.d(TAG,"[onCreatePanelMenu] returning " + result);
    return result;
  }
  return false;
}
 

Example 20

From project ActionBarSherlock, under directory /library/src/android/support/v4/app/.

Source file: Watson.java

  15 
vote

@Override public boolean onPreparePanel(int featureId,View view,Menu menu){
  if (DEBUG)   Log.d(TAG,"[onPreparePanel] featureId: " + featureId + ", view: "+ view+ " menu: "+ menu);
  if (featureId == Window.FEATURE_OPTIONS_PANEL) {
    boolean result=onPrepareOptionsMenu(menu);
    if (DEBUG)     Log.d(TAG,"[onPreparePanel] activity prepare result: " + result);
    boolean show=false;
    if (mFragments.mAdded != null) {
      for (int i=0; i < mFragments.mAdded.size(); i++) {
        Fragment f=mFragments.mAdded.get(i);
        if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnPrepareOptionsMenuListener) {
          show=true;
          ((OnPrepareOptionsMenuListener)f).onPrepareOptionsMenu(menu);
        }
      }
    }
    if (DEBUG)     Log.d(TAG,"[onPreparePanel] fragments prepare result: " + show);
    result|=show;
    result&=menu.hasVisibleItems();
    if (DEBUG)     Log.d(TAG,"[onPreparePanel] returning " + result);
    return result;
  }
  return false;
}