当前位置: 首页>>代码示例>>Java>>正文


Java Handler类代码示例

本文整理汇总了Java中android.os.Handler的典型用法代码示例。如果您正苦于以下问题:Java Handler类的具体用法?Java Handler怎么用?Java Handler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Handler类属于android.os包,在下文中一共展示了Handler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initPullToRefreshLayout

import android.os.Handler; //导入依赖的package包/类
private void initPullToRefreshLayout(){
    pullToRefreshLayout.setRefreshListener(new BaseRefreshListener() {
        @Override
        public void refresh() {
            if(list.isEmpty()){
                pullToRefreshLayout.showView(ViewStatus.LOADING_STATUS);
            }
            getP().refresh(searchText);
        }

        @Override
        public void loadMore() {
            getP().loadMore(searchText);
        }
    });

    pullToRefreshLayout.showView(ViewStatus.LOADING_STATUS);
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            getP().refresh();
        }
    }, 500);
}
 
开发者ID:ruiqiao2017,项目名称:Renrentou,代码行数:25,代码来源:AdCompanySearchActivity.java

示例2: WebRTCModule

import android.os.Handler; //导入依赖的package包/类
public WebRTCModule(ReactApplicationContext reactContext) {
    super(reactContext);

    imageProcessingThread = new HandlerThread("PictureProcessing");
    imageProcessingThread.start();
    imagePorcessingHandler = new Handler(imageProcessingThread.getLooper());

    mPeerConnectionObservers = new SparseArray<PeerConnectionObserver>();
    mMediaStreams = new HashMap<String, MediaStream>();
    mMediaStreamTracks = new HashMap<String, MediaStreamTrack>();
    mVideoCapturers = new HashMap<String, VideoCapturer>();
    mCameras = new HashMap<>();

    pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true"));
    pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveVideo", "true"));
    pcConstraints.optional.add(new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true"));

    PeerConnectionFactory.initializeAndroidGlobals(reactContext, true, true, true);
    mFactory = new PeerConnectionFactory();
}
 
开发者ID:angellsl10,项目名称:react-native-webrtc,代码行数:21,代码来源:WebRTCModule.java

示例3: Twitter

import android.os.Handler; //导入依赖的package包/类
public Twitter(ComponentContainer container) {
  super(container.$form());
  this.container = container;
  handler = new Handler();

  mentions = new ArrayList<String>();
  followers = new ArrayList<String>();
  timeline = new ArrayList<List<String>>();
  directMessages = new ArrayList<String>();
  searchResults = new ArrayList<String>();

  sharedPreferences = container.$context().getSharedPreferences("Twitter",
      Context.MODE_PRIVATE);
  accessToken = retrieveAccessToken();

  requestCode = form.registerForActivityResult(this);
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:18,代码来源:Twitter.java

示例4: initSpeechRecognizer

import android.os.Handler; //导入依赖的package包/类
private void initSpeechRecognizer() {
    Log.e(TAG, "initSpeechRecognizer: ");

    Handler handler = getHandler();

    mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(mContext);
    final Intent recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    recognizerIntent.putExtra(
            RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
            mContext.getPackageName());

    mSpeechRecognizer.setRecognitionListener(new SpeechListener(handler));
    mSpeechRecognizer.startListening(recognizerIntent);
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            mSpeechRecognizer.stopListening();
        }
    }, DELAY_MILLIS);
}
 
开发者ID:shashi2459,项目名称:notify-me,代码行数:22,代码来源:HeadPhoneListener.java

示例5: allAnimation

import android.os.Handler; //导入依赖的package包/类
private void allAnimation() {

        //Animation
        final Animation myAnim = AnimationUtils.loadAnimation(this, R.anim.bounce);
        // Use bounce interpolator with amplitude 0.2 and frequency 20
        MyBounceInterpolator interpolator = new MyBounceInterpolator(0.11, 10);
        myAnim.setInterpolator(interpolator);
        tvQ.startAnimation(myAnim);


        final Handler handler = new Handler();
        Runnable runnable = new Runnable() {

            public void run() {
                master.startAnimation(inFromLeftAnimation());
                master.setVisibility(View.VISIBLE);   //for interval...
            }
        };
        handler.postDelayed(runnable, 150); //for initial delay..*//*

        for (int i = 0; i < 20; i++) {
            textViewArrayAbove[i].startAnimation(myAnim);
        }
    }
 
开发者ID:sarveshchavan7,项目名称:Trivia-Knowledge,代码行数:25,代码来源:MainGameActivity.java

示例6: removeNotificationsForSMS

import android.os.Handler; //导入依赖的package包/类
public void removeNotificationsForSMS(String smsPackage, String from, String address, String displayAddress, String body, long timestamp) {
    if (!this.keepNotificationsInDrawer) {
        final String str = smsPackage;
        final String str2 = from;
        final String str3 = address;
        final String str4 = displayAddress;
        final String str5 = body;
        final long j = timestamp;
        Handler handler = new Handler() {
            public void handleMessage(Message msg) {
                Intent i = new Intent(NotificationService.INTENT_ACTION_CMDS);
                i.putExtra("command", NotificationService.CMD_REMOVE_SMS);
                i.putExtra(NotificationService.KEY_SMS_PACKAGE, str);
                i.putExtra(NotificationService.KEY_SMS_FROM, str2);
                i.putExtra(NotificationService.KEY_SMS_ADDRESS, str3);
                i.putExtra(NotificationService.KEY_SMS_DISPLAY_ADDRESS, str4);
                i.putExtra(NotificationService.KEY_SMS_BODY, str5);
                i.putExtra(NotificationService.KEY_SMS_TIMESTAMP, j);
                NotificationManager.this.context.sendBroadcast(i);
            }
        };
        handler.sendMessageDelayed(handler.obtainMessage(), 3000);
    }
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:25,代码来源:NotificationManager.java

示例7: getHaierNspList

import android.os.Handler; //导入依赖的package包/类
/**
 * 
 * 获取海尔人报列表
 * 
 * @Description<功能详细描述>
 * 
 * @param task
 * @param handler
 * @param requestType
 * @param maxId
 * @param pageSize
 * @return
 * @LastModifiedDate:2016年10月28日
 * @author wl
 * @EditHistory:<修改内容><修改人>
 */
public static NetTask getHaierNspList(NetTask task, Handler handler, int requestType, String maxId, String pageSize)
{
    
    JSONObject bodyVaule = new JSONObject();
    try
    {
        bodyVaule.put("maxId", maxId);
        bodyVaule.put("pageSize", pageSize);
    }
    catch (JSONException e)
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    JSONObject requestObj =
        NetRequestController.getPredefineObj("newspaper",
            "HaierNspAdapter",
            "getHaierNspList",
            "general",
            bodyVaule);
    
    return NetRequestController.sendStrBaseServlet(task, handler, requestType, requestObj);
}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:40,代码来源:HERBServiceImpl.java

示例8: UpgradeActivity

import android.os.Handler; //导入依赖的package包/类
public UpgradeActivity() {
    mHandler = new Handler(Looper.getMainLooper());

    mObserver = new DocumentModeAssassinObserver() {
        @Override
        public void onStageChange(int newStage) {
            if (newStage != DocumentModeAssassin.STAGE_DONE) return;
            DocumentModeAssassin.getInstance().removeObserver(this);

            // Always post to avoid any issues that could arise from firing the Runnable
            // while other Observers are being alerted.
            long msElapsed = System.currentTimeMillis() - mStartTimestamp;
            long msRemaining = Math.max(0, MIN_MS_TO_DISPLAY_ACTIVITY - msElapsed);
            mHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    continueApplicationLaunch();
                }
            }, msRemaining);
        }
    };
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:23,代码来源:UpgradeActivity.java

示例9: onBackPressed

import android.os.Handler; //导入依赖的package包/类
/**
 * discard back press if MainFragment loaded, double tap to app exit
 */
@Override
public void onBackPressed() {
    Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragmentLayout);
    if(fragment instanceof MainFragment || fragment instanceof LoginFragment){
        if(doubleBackToExit) {
            finish();
            return;
        }

        doubleBackToExit = true;
        Toast.makeText(this, getString(R.string.double_back_info), Toast.LENGTH_SHORT).show();

        new Handler().postDelayed(() -> doubleBackToExit = false, 2000);

        return;
    }

    super.onBackPressed();
}
 
开发者ID:jakdor,项目名称:LabDayApp,代码行数:23,代码来源:MainActivity.java

示例10: sendGetResultDetailRequest

import android.os.Handler; //导入依赖的package包/类
/**
 * 
 * 获取详情
 * 
 * @Description<功能详细描述>
 * 
 * @param task
 * @param handler
 * @param requestType
 * @param id 决议/汇报id
 * @return
 * @LastModifiedDate:2016年9月21日
 * @author wl
 * @EditHistory:<修改内容><修改人>
 */
public static NetTask sendGetResultDetailRequest(NetTask task, Handler handler, int requestType, String id)
{
    
    JSONObject bodyVaule = new JSONObject();
    try
    {
        bodyVaule.put("id", id);
    }
    catch (JSONException e)
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    JSONObject requestObj =
        NetRequestController.getPredefineObj("result", "ResultAdapter", "getResultDetail", "general", bodyVaule);
    
    return NetRequestController.sendStrBaseServlet(task, handler, requestType, requestObj);
}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:34,代码来源:JueYiSeviceImpl.java

示例11: showKeyboard

import android.os.Handler; //导入依赖的package包/类
public static void showKeyboard(final Activity activity, final EditText editText, final int i, String text, String hint) {
    editText.requestFocus();
    editText.hasFocus();
    editText.setText(text);
    editText.setHint(hint);
    editText.setSelection(editText.length());
    new Handler().postDelayed(new Runnable() {
        public void run() {
            SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(activity);
            sharedPref.edit().putInt("keyboard", i).apply();
            activity.invalidateOptionsMenu();
            InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(editText, InputMethodManager.SHOW_FORCED);
        }
    }, 200);
}
 
开发者ID:JaeNuguid,项目名称:Kids-Portal-Android,代码行数:17,代码来源:helper_editText.java

示例12: MuPDFReflowView

import android.os.Handler; //导入依赖的package包/类
public MuPDFReflowView(Context c, MuPDFCore core, Point parentSize) {
	super(c);
	mHandler = new Handler();
	mCore = core;
	mParentSize = parentSize;
	mScale = 1.0f;
	mContentHeight = parentSize.y;
	getSettings().setJavaScriptEnabled(true);
	addJavascriptInterface(new Object(){
		public void reportContentHeight(String value) {
			mContentHeight = (int)Float.parseFloat(value);
			mHandler.post(new Runnable() {
				public void run() {
					requestLayout();
				}
			});
		}
	}, "HTMLOUT");
	setWebViewClient(new WebViewClient() {
		@Override
		public void onPageFinished(WebView view, String url) {
			setScale(mScale);
		}
	});
}
 
开发者ID:ArtifexSoftware,项目名称:mupdf-android-viewer-old,代码行数:26,代码来源:MuPDFReflowView.java

示例13: onUserUpdated

import android.os.Handler; //导入依赖的package包/类
public void onUserUpdated(@Nullable UserDetail user) {
    if (user != null) {

        if (binding.viewPager.getAdapter() == null) {
            new Handler(Looper.myLooper()).postDelayed(this::initPager, 300);
        }

        binding.tvName.setText(user.getDisplayName());
        binding.tvLink.setText(user.getHtmlUrl());

        if (InputHelper.isEmpty(user.getBio())) {
            binding.tvBio.setVisibility(View.GONE);
        } else {
            binding.tvBio.setVisibility(View.VISIBLE);
            binding.tvBio.setText(user.getBio());
        }
        GlideUtils.loadImageBitmap(this, user.getAvatarUrl(), bitmap -> {
            binding.imvAvatar.setImageBitmap(bitmap);
            Blurry.with(this).radius(25).from(bitmap).into(binding.imvBackground);
        });
    }
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:23,代码来源:ProfileActivity.java

示例14: onCreate

import android.os.Handler; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    background = (ImageView) findViewById(R.id.s_img);



    Glide.with(this)
            .load(R.drawable.splash)
            .into(background);

    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            //Do something after 100ms
            finish();
            startActivity(new Intent(Splash.this, Home.class));
        }
    }, 3000);
}
 
开发者ID:sid24rane,项目名称:Personal-Chef,代码行数:23,代码来源:Splash.java

示例15: ThreadHelper

import android.os.Handler; //导入依赖的package包/类
private ThreadHelper() {
    mMainHandler = new Handler(Looper.getMainLooper());
    ThreadFactory threadFactory = new ThreadFactory() {
        private final AtomicInteger mCount = new AtomicInteger(1);

        @Override
        public Thread newThread(Runnable r) {
            return new Thread(r, "ThreadHelper #".concat(String.valueOf(mCount.getAndIncrement())));
        }
    };
    int cpuCount = Runtime.getRuntime().availableProcessors();
    int corePoolSize = cpuCount + 1;
    int maxPoolSize = cpuCount * 2 + 1;
    BlockingQueue<Runnable> queue = new ArrayBlockingQueue<>(128);
    mExecutorService = new ThreadPoolExecutor(corePoolSize, maxPoolSize, 10, TimeUnit.SECONDS, queue, threadFactory);
}
 
开发者ID:isuperqiang,项目名称:AndEasyLog,代码行数:17,代码来源:ThreadHelper.java


注:本文中的android.os.Handler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。