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

The following examples show how to use android.view.View#getHandler() . 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 check out the related API usage on the sidebar.
Example 1
Source File: RippleManager.java    From MDPreference with Apache License 2.0 7 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 File: RippleManager.java    From material with Apache License 2.0 7 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
Source File: FirstPageFragment.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
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
Source File: FirstPageFragment.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
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
Source File: FirstPageFragment.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
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
Source File: FirstPageFragment.java    From NightWatch with GNU General Public License v3.0 6 votes vote down vote up
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
Source File: ThreadedInputConnectionFactory.java    From 365browser with Apache License 2.0 5 votes vote down vote up
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
Source File: FirstPageFragment.java    From NightWatch with GNU General Public License v3.0 5 votes vote down vote up
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();

}