Java Code Examples for android.view.View#getHandler()

The following examples show how to use android.view.View#getHandler() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: MDPreference   File: RippleManager.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
	Drawable background = v.getBackground();
	long delay = 0;

	if(background != null) {
		if (background instanceof RippleDrawable)
			delay = ((RippleDrawable) background).getClickDelayTime();
		else if (background instanceof ToolbarRippleDrawable)
			delay = ((ToolbarRippleDrawable) background).getClickDelayTime();
	}
		
	if(delay > 0 && v.getHandler() != null && !mClickScheduled) {
           mClickScheduled = true;
           v.getHandler().postDelayed(new ClickRunnable(v), delay);
       }
	else
		dispatchClickEvent(v);
}
 
Example 2
Source Project: material   File: RippleManager.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
	Drawable background = v.getBackground();
	long delay = 0;

	if(background != null) {
		if (background instanceof RippleDrawable)
			delay = ((RippleDrawable) background).getClickDelayTime();
		else if (background instanceof ToolbarRippleDrawable)
			delay = ((ToolbarRippleDrawable) background).getClickDelayTime();
	}
		
	if(delay > 0 && v.getHandler() != null) {
		if(!mClickScheduled){
           			mClickScheduled = true;
           			v.getHandler().postDelayed(new ClickRunnable(v), delay);
		}
       	}
	else
		dispatchClickEvent(v);
}
 
Example 3
private void updateText(final View localView, final TextView tv, final String s) {
    Log.d("DrawStats", "updateText: " + s);
    Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {

            //Adrian: after screen rotation it might take some time to attach the view to the window
            //Wait up to 3 seconds for this to happen.
            int i = 0;
            while (localView.getHandler() == null && i < 10) {
                i++;
                try {
                    Thread.sleep(300);
                } catch (InterruptedException e) {
                }

            }

            if (localView.getHandler() == null) {
                Log.d("DrawStats", "no Handler found - stopping to update view");
                return;
            }


            boolean success = localView.post(new Runnable() {
                @Override
                public void run() {
                    tv.setText(s);
                    Log.d("DrawStats", "setText actually called: " + s);

                }
            });
            Log.d("DrawStats", "updateText: " + s + " success: " + success);
        }
    });
    thread.start();

}
 
Example 4
private void updateText(final View localView, final TextView tv, final String s) {
    Log.d("DrawStats", "updateText: " + s);
    Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {

            //Adrian: after screen rotation it might take some time to attach the view to the window
            //Wait up to 3 seconds for this to happen.
            int i = 0;
            while (localView.getHandler() == null && i < 10) {
                i++;
                try {
                    Thread.sleep(300);
                } catch (InterruptedException e) {
                }

            }

            if (localView.getHandler() == null) {
                Log.d("DrawStats", "no Handler found - stopping to update view");
                return;
            }


            boolean success = localView.post(new Runnable() {
                @Override
                public void run() {
                    tv.setText(s);
                    Log.d("DrawStats", "setText actually called: " + s);

                }
            });
            Log.d("DrawStats", "updateText: " + s + " success: " + success);
        }
    });
    thread.start();

}
 
Example 5
private void updateText(final View localView, final TextView tv, final String s) {
    Log.d("DrawStats", "updateText: " + s);
    Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {

            //Adrian: after screen rotation it might take some time to attach the view to the window
            //Wait up to 3 seconds for this to happen.
            int i = 0;
            while (localView.getHandler() == null && i < 10) {
                i++;
                try {
                    Thread.sleep(300);
                } catch (InterruptedException e) {
                }

            }

            if (localView.getHandler() == null) {
                Log.d("DrawStats", "no Handler found - stopping to update view");
                return;
            }


            boolean success = localView.post(new Runnable() {
                @Override
                public void run() {
                    tv.setText(s);
                    Log.d("DrawStats", "setText actually called: " + s);

                }
            });
            Log.d("DrawStats", "updateText: " + s + " success: " + success);
        }
    });
    thread.start();

}
 
Example 6
private void updateText(final View localView, final TextView tv, final String s) {
    Log.d("DrawStats", "updateText: " + s);
    Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {

            //Adrian: after screen rotation it might take some time to attach the view to the window
            //Wait up to 3 seconds for this to happen.
            int i = 0;
            while (localView.getHandler() == null && i < 10) {
                i++;
                try {
                    Thread.sleep(300);
                } catch (InterruptedException e) {
                }

            }

            if (localView.getHandler() == null) {
                Log.d("DrawStats", "no Handler found - stopping to update view");
                return;
            }


            boolean success = localView.post(new Runnable() {
                @Override
                public void run() {
                    tv.setText(s);
                    Log.d("DrawStats", "setText actually called: " + s);

                }
            });
            Log.d("DrawStats", "updateText: " + s + " success: " + success);
        }
    });
    thread.start();

}
 
Example 7
private void postCheckRegisterResultOnUiThread(final View view,
        final CheckInvalidator checkInvalidator, final int retry) {
    // Now posting on UI thread to access view methods.
    final Handler viewHandler = view.getHandler();
    if (viewHandler == null) return;
    viewHandler.post(new Runnable() {
        @Override
        public void run() {
            checkRegisterResult(view, checkInvalidator, retry);
        }
    });
}
 
Example 8
private void updateText(final View localView, final TextView tv, final String s) {
    Log.d("DrawStats", "updateText: " + s);
    Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {

            //Adrian: after screen rotation it might take some time to attach the view to the window
            //Wait up to 3 seconds for this to happen.
            int i = 0;
            while (localView.getHandler() == null && i < 10) {
                i++;
                try {
                    Thread.sleep(300);
                } catch (InterruptedException e) {
                }

            }

            if (localView.getHandler() == null) {
                Log.d("DrawStats", "no Handler found - stopping to update view");
                return;
            }


            boolean success = localView.post(new Runnable() {
                @Override
                public void run() {
                    tv.setText(s);
                    Log.d("DrawStats", "setText actually called: " + s);

                }
            });
            Log.d("DrawStats", "updateText: " + s + " success: " + success);
        }
    });
    thread.start();

}