List of usage examples for android.os Handler postDelayed
public final boolean postDelayed(Runnable r, long delayMillis)
From source file:crackerjack.education.Indijisites.StartUp.java
@Override public boolean onMarkerClick(final Marker marker) { // This method makes the marker bounce when you click on it. It's not really needed, but it's a neat feature. // Will expand this if offered more time. if (marker.equals(mBrisbane)) { final Handler handler = new Handler(); final long start = SystemClock.uptimeMillis(); Projection proj = mMap.getProjection(); Point startPoint = proj.toScreenLocation(BRISBANE); startPoint.offset(0, -100);/*w ww. ja v a2 s . c om*/ final LatLng startLatLng = proj.fromScreenLocation(startPoint); final long duration = 1500; final Interpolator interpolator = new BounceInterpolator(); handler.post(new Runnable() { @Override public void run() { long elapsed = SystemClock.uptimeMillis() - start; float t = interpolator.getInterpolation((float) elapsed / duration); double lng = t * BRISBANE.longitude + (1 - t) * startLatLng.longitude; // This allows the marker to pinpoint if offscreen (I think =/) double lat = t * BRISBANE.latitude + (1 - t) * startLatLng.latitude; marker.setPosition(new LatLng(lat, lng)); if (t < 1.0) { // Post again 16ms later handler.postDelayed(this, 16); } } }); } //False is returned to indicate we have not consumed the event and that we wish //for the default behaviour to occur (move to marker location). return false; }
From source file:com.bellman.bible.android.view.activity.base.ProgressActivityBase.java
private void initialiseView() { // prepare to show no tasks msg noTasksMessageView = (TextView) findViewById(R.id.noTasksRunning); taskKillWarningView = (TextView) findViewById(R.id.progressStatusMessage); Iterator<Progress> jobsIterator = JobManager.iterator(); while (jobsIterator.hasNext()) { Progress job = jobsIterator.next(); findOrCreateUIControl(job);/*from w w w. j av a 2 s .c om*/ } // allow call back and continuation in the ui thread after JSword has been initialised final Handler uiHandler = new Handler(); final Runnable uiUpdaterRunnable = new Runnable() { @Override public void run() { Progress prog = progressNotificationQueue.poll(); if (prog != null) { updateProgress(prog); } } }; // listen for Progress changes and call the above Runnable to update the ui workListener = new WorkListener() { @Override public void workProgressed(WorkEvent ev) { callUiThreadUpdateHandler(ev); } @Override public void workStateChanged(WorkEvent ev) { callUiThreadUpdateHandler(ev); } private void callUiThreadUpdateHandler(WorkEvent ev) { Progress prog = ev.getJob(); progressNotificationQueue.offer(prog); // switch back to ui thread to continue uiHandler.post(uiUpdaterRunnable); } }; JobManager.addWorkListener(workListener); // give new jobs a chance to start then show 'No Job' msg if nothing running uiHandler.postDelayed(new Runnable() { @Override public void run() { if (!JobManager.iterator().hasNext()) { showNoTaskMsg(true); } } }, 4000); }
From source file:com.spoiledmilk.ibikecph.navigation.SMRouteNavigationActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.route_navigation_activity); LayoutInflater inflater = LayoutInflater.from(this); reportProblemsView = (RelativeLayout) inflater.inflate(R.layout.report_problems_view, null); textReport = (TextView) reportProblemsView.findViewById(R.id.textReport); instructionsViewMaxContainer = (RelativeLayout) findViewById(R.id.instructionsViewMaxContainer); paramsForInstMaxContainer = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); paramsForInstMaxContainer.addRule(RelativeLayout.ALIGN_PARENT_TOP); paramsForInstMaxContainer.addRule(RelativeLayout.CENTER_HORIZONTAL); paramsForInstMaxContainer.topMargin = 0; instructionsViewMaxContainer.setLayoutParams(paramsForInstMaxContainer); routeFinishedContainer = (RelativeLayout) findViewById(R.id.routeFinishedContainer); imgClose = (ImageButton) findViewById(R.id.imgClose); imgClose.setOnClickListener(new OnClickListener() { @Override//from w w w.j a v a2s .c om public void onClick(View arg0) { Bundle conData = new Bundle(); conData.putInt("overlaysShown", getOverlaysShown()); Intent intent = new Intent(); intent.putExtras(conData); setResult(MapActivity.RESULT_RETURN_FROM_NAVIGATION, intent); setResult(MapActivity.RESULT_RETURN_FROM_NAVIGATION); finish(); overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right); } }); progressBar = (ProgressBar) findViewById(R.id.progressBar); textGoodRide = (TextView) findViewById(R.id.textGoodRide); textRecalculating = (TextView) findViewById(R.id.textRecalculating); textBicycle = (TextView) findViewById(R.id.textBicycle); textCargo = (TextView) findViewById(R.id.textCargo); textGreen = (TextView) findViewById(R.id.textGreen); FrameLayout.LayoutParams rootParams = new FrameLayout.LayoutParams((int) (9 * Util.getScreenWidth() / 5), FrameLayout.LayoutParams.MATCH_PARENT); findViewById(R.id.root_layout).setLayoutParams(rootParams); this.maxSlide = (int) (4 * Util.getScreenWidth() / 5); Util.init(getWindowManager()); leftContainer = (RelativeLayout) findViewById(R.id.leftContainer); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int) Util.getScreenWidth() * 4 / 5, RelativeLayout.LayoutParams.MATCH_PARENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); leftContainer.setLayoutParams(params); parentContainer = (RelativeLayout) findViewById(R.id.parent_container); params = new RelativeLayout.LayoutParams((int) Util.getScreenWidth(), RelativeLayout.LayoutParams.MATCH_PARENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); parentContainer.setLayoutParams(params); imgCargoSlider = (ImageView) findViewById(R.id.imgCargoSlider); imgCargoSlider.setOnTouchListener(new OnTouchListener() { // Swipe the view horizontally @Override public boolean onTouch(View v, MotionEvent event) { return onSliderTouch(v, event); } }); darkenedView = findViewById(R.id.darkenedView); darkenedView.setBackgroundColor(Color.BLACK); viewDistance = (RelativeLayout) findViewById(R.id.viewDistance); textTime = (TextView) findViewById(R.id.textTime); mapDisabledView = findViewById(R.id.mapDisabledView); mapDisabledView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // used to disable the map touching when sliden return onSliderTouch(v, event); } }); paramsInstructionsMaxNormal.topMargin = (int) (Util.getScreenHeight() - Util.dp2px(146)); paramsInstructionsMaxNormal.bottomMargin = -(int) ((Util.getScreenHeight())); paramsInstructionsMaxMaximized.topMargin = INSTRUCTIONS_TOP_MARGIN; paramsInstructionsMaxMinimized.topMargin = (int) (Util.getScreenHeight() - Util.getScreenHeight() / 10); paramsInstructionsMaxMinimized.bottomMargin = -(int) ((Util.getScreenHeight())); overviewLayout = (RelativeLayout) findViewById(R.id.overviewLayout); btnStart = (Button) overviewLayout.findViewById(R.id.btnStart); btnStart.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { viewDistance.setVisibility(View.VISIBLE); btnStart.setEnabled(false); hideOverview(); textTime.setText(mapFragment.getEstimatedArrivalTime()); mapFragment.startRouting(); IbikeApplication.getTracker().sendEvent("Route", "Overview", mapFragment.destination, (long) 0); // instructionsView.setVisibility(View.VISIBLE); setInstructionViewState(InstrcutionViewState.Normal); RelativeLayout.LayoutParams paramsBtnTrack = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); paramsBtnTrack.setMargins(Util.dp2px(10), Util.dp2px(10), Util.dp2px(10), Util.dp2px(10)); paramsBtnTrack.alignWithParent = true; paramsBtnTrack.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); paramsBtnTrack.addRule(RelativeLayout.ABOVE, instructionsView.getId()); btnTrack.setLayoutParams(paramsBtnTrack); startTrackingUser(); } }); btnClose = ((ImageButton) findViewById(R.id.btnClose)); btnClose.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showStopDlg(); } }); // Darken the button on touch : btnClose.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent me) { if (me.getAction() == MotionEvent.ACTION_DOWN) { btnClose.setColorFilter(Color.argb(150, 155, 155, 155)); return false; } else if (me.getAction() == MotionEvent.ACTION_UP || me.getAction() == MotionEvent.ACTION_CANCEL) { btnClose.setColorFilter(Color.argb(0, 155, 155, 155)); return false; } return false; } }); // increased touch area for the normal pull handle pullTouchNormal = findViewById(R.id.pullTouchNormal); pullTouchNormal.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent event) { isPulledFromNormal = true; return onPullHandleTouch(null, event); } }); // increased touch area for the max pull handle pullTouchMax = findViewById(R.id.pullTouchMax); pullTouchMax.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent event) { isPulledFromNormal = false; yFix = Util.dp2px(16); return onPullHandleTouch(null, event); } }); mapTopDisabledView = findViewById(R.id.mapTopDisabledView); mapTopDisabledView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent event) { isPulledFromNormal = false; yFix = Util.dp2px(42); // return onPullHandleTouch(null, event); return true; } }); instructionsView = (RelativeLayout) findViewById(R.id.instructionsView); instructionsView.setBackgroundColor(Color.BLACK); pullHandle = (ImageButton) instructionsView.findViewById(R.id.imgPullHandle); pullHandle.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent event) { isPulledFromNormal = true; return onPullHandleTouch(null, event); } }); instructionsViewMin = (LinearLayout) findViewById(R.id.instructionsViewMin); pullHandleMin = (ImageButton) instructionsViewMin.findViewById(R.id.imgPullHandleMin); pullHandleMin.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { return onPullHandleTouch(arg0, arg1); } }); instructionsViewMax = (RelativeLayout) findViewById(R.id.instructionsViewMax); params = new RelativeLayout.LayoutParams((int) Util.getScreenWidth(), RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); instructionsView.setLayoutParams(params); params = new RelativeLayout.LayoutParams((int) Util.getScreenWidth(), RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); findViewById(R.id.overviewLayout).setLayoutParams(params); pullHandleMax = (ImageButton) instructionsViewMax.findViewById(R.id.imgPullHandleMax); pullHandleMax.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { isPulledFromNormal = false; return onPullHandleTouch(arg0, arg1); } }); instructionList = (ListView) instructionsViewMax.findViewById(R.id.listView); instructionList.addFooterView(reportProblemsView); setInstructionViewState(InstrcutionViewState.Invisible); FragmentManager fm = this.getSupportFragmentManager(); mapFragment = getMapFragment(); fm.beginTransaction().add(R.id.map_container, mapFragment).commit(); viewPager = (ViewPager) instructionsView.findViewById(R.id.viewPager); // viewPager = (ViewPager) findViewById(R.id.viewPager); viewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int position) { if (!instructionsUpdated || (mapFragment.isRecalculation && !mapFragment.getTrackingMode())) { SMTurnInstruction turn = mapFragment.route.getTurnInstructions().get(position); if (turn.drivingDirection == SMTurnInstruction.TurnDirection.ReachedYourDestination || turn.drivingDirection == SMTurnInstruction.TurnDirection.ReachingDestination) { mapFragment.animateTo(mapFragment.route.getEndLocation()); } else { mapFragment.animateTo(turn.getLocation()); } stopTrackingUser(); } } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int arg0) { } }); pagerAdapter = getPagerAdapter(); viewPager.setAdapter(pagerAdapter); viewPager.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // used to disable viewPager swiping when the left menu is // opened return slidden; } }); btnTrack = (ImageButton) findViewById(R.id.btnTrack); btnTrack.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!mapFragment.getTrackingMode()) { startTrackingUser(); } else { mapFragment.switchTracking(); changeTrackingIcon(); } } }); textReport.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { launchReportIssuesActivity(); } }); textReport2 = (TextView) findViewById(R.id.textReport2); textReport2.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { launchReportIssuesActivity(); } }); textDestAddress = (TextView) findViewById(R.id.textDestAddress); textDestAddress.setTypeface(IbikeApplication.getNormalFont()); Config.OSRM_SERVER = Config.OSRM_SERVER_FAST; if (savedInstanceState != null) { final Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { Intent intent = new Intent(SMRouteNavigationActivity.this, getSplashActivityClass()); intent.putExtra("timeout", 0); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); } }, 400); } instructionsViewMax.setLayoutParams(paramsInstructionsMaxNormal); RelativeLayout.LayoutParams paramsBtnTrack = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); paramsBtnTrack.setMargins(Util.dp2px(10), Util.dp2px(10), Util.dp2px(10), Util.dp2px(10)); paramsBtnTrack.alignWithParent = true; paramsBtnTrack.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); paramsBtnTrack.addRule(RelativeLayout.ABOVE, overviewLayout.getId()); btnTrack.setLayoutParams(paramsBtnTrack); instructionsView.measure(0, 0); instructionsViewHeight = instructionsView.getMeasuredHeight(); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); }
From source file:com.google.android.marvin.screenspeak.ScreenSpeakService.java
public void resetFocusedNode(long delay) { final Handler handler = new Handler(); handler.postDelayed(new Runnable() { @SuppressLint("InlinedApi") @Override/*w ww .j av a 2s . c om*/ public void run() { AccessibilityNodeInfoCompat node = mSavedNode.getNode(); if (node == null) { return; } AccessibilityNodeInfoCompat refreshed = AccessibilityNodeInfoUtils.refreshNode(node); if (refreshed != null) { if (!refreshed.isAccessibilityFocused()) { mCursorController.setGranularity(mSavedNode.getGranularity(), refreshed, false); SavedNode.Selection selection = mSavedNode.getSelection(); if (selection != null) { Bundle args = new Bundle(); args.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, selection.start); args.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, selection.end); PerformActionUtils.performAction(refreshed, AccessibilityNodeInfoCompat.ACTION_SET_SELECTION, args); } PerformActionUtils.performAction(refreshed, AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS); } refreshed.recycle(); } mSavedNode.recycle(); } }, delay); }
From source file:com.trackdroid.activities.ShowInMapActivity.java
@Override public boolean onMarkerClick(final Marker marker) { if (marker.equals(mPerth)) { // This causes the marker at Perth to bounce into position when it // is clicked. final Handler handler = new Handler(); final long start = SystemClock.uptimeMillis(); final long duration = 1500; final Interpolator interpolator = new BounceInterpolator(); handler.post(new Runnable() { @Override// ww w .j a v a2 s. com public void run() { long elapsed = SystemClock.uptimeMillis() - start; float t = Math.max(1 - interpolator.getInterpolation((float) elapsed / duration), 0); marker.setAnchor(0.5f, 1.0f + 2 * t); if (t > 0.0) { // Post again 16ms later. handler.postDelayed(this, 16); } } }); } else if (marker.equals(mAdelaide)) { // This causes the marker at Adelaide to change color and alpha. marker.setIcon(BitmapDescriptorFactory.defaultMarker(mRandom.nextFloat() * 360)); marker.setAlpha(mRandom.nextFloat()); } // We return false to indicate that we have not consumed the event and // that we wish // for the default behavior to occur (which is for the camera to move // such that the // marker is centered and for the marker's info window to open, if it // has one). return false; }
From source file:com.mezcaldev.hotlikeme.ChatActivity.java
private void updateFireBaseRecyclerAdapter() { if (mFirebaseAdapter != null) { mFirebaseAdapter.cleanup();//from w ww . ja v a2 s .com } mFirebaseAdapter = new FirebaseRecyclerAdapter<ChatMessageModel, MessageViewHolder>(ChatMessageModel.class, R.layout.item_message_left, MessageViewHolder.class, recentMessages) { private static final int RIGHT_MSG = 0; private static final int LEFT_MSG = 1; @Override public MessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view; if (viewType == RIGHT_MSG) { view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_message_right, parent, false); return new MessageViewHolder(view); } else { view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_message_left, parent, false); return new MessageViewHolder(view); } } @Override public int getItemViewType(int position) { ChatMessageModel model = getItem(position); if (model.getUserId().equals(mFirebaseUser.getUid())) { return RIGHT_MSG; } else { return LEFT_MSG; } } @Override protected void populateViewHolder(final MessageViewHolder viewHolder, final ChatMessageModel chatMessageModel, int position) { String messengerText = dateFormatter(chatMessageModel.getTimeStamp()); //System.out.println("SIZE -------> " + positionMessages); int positionToLoadMessage; if (positionMessages - MESSAGE_LIMIT >= 0) { positionToLoadMessage = position + (positionMessages - MESSAGE_LIMIT); } else { positionToLoadMessage = position; } viewHolder.messageTextView.setText(decryptedMessages.get(positionToLoadMessage)); viewHolder.messengerTextView.setText(messengerText); if (chatMessageModel.getPhotoUrl() == null) { viewHolder.messengerImageView.setImageDrawable( ContextCompat.getDrawable(ChatActivity.this, R.drawable.ic_account_circle_black_24dp)); } else { Glide.with(ChatActivity.this).load(chatMessageModel.getPhotoUrl()) .into(viewHolder.messengerImageView); } } }; mMessageRecyclerView.setLayoutManager(mLinearLayoutManager); mMessageRecyclerView.setAdapter(mFirebaseAdapter); mFirebaseAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() { @Override public void onItemRangeInserted(int positionStart, int itemCount) { super.onItemRangeInserted(positionStart, itemCount); int friendlyMessageCount = mFirebaseAdapter.getItemCount(); int lastVisiblePosition = mLinearLayoutManager.findLastCompletelyVisibleItemPosition(); // If the recycler view is initially being loaded or the user is at the bottom of the list, scroll // to the bottom of the list to show the newly added message. if (lastVisiblePosition >= -1 || (positionStart >= (friendlyMessageCount - 1) && lastVisiblePosition == (positionStart - 1))) { mLinearLayoutManager.setStackFromEnd(true); mLinearLayoutManager.scrollToPosition(positionStart); if (mFirebaseAdapter != null) { mFirebaseAdapter.notifyDataSetChanged(); } } Handler handlerSetAsRead = new Handler(); Runnable runnableSetAsRead = new Runnable() { @Override public void run() { if (isInFront && !mFirebaseAdapter.getItem(mFirebaseAdapter.getItemCount() - 1).getUserId() .equals(mFirebaseUser.getUid())) { //Log.i(TAG, "====> Item count: " + getItemCount() + " Item Position: " + position); mFirebaseDatabaseReference.child(MESSAGES_RESUME).child("readIt").setValue(true); } } }; handlerSetAsRead.postDelayed(runnableSetAsRead, 2000); } }); Handler reloadView = new Handler(); reloadView.postDelayed(new Runnable() { @Override public void run() { mFirebaseAdapter.notifyDataSetChanged(); } }, UPDATE_VIEW_DELAY); }
From source file:com.simadanesh.isatis.ScreenSlideActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); try {/*w w w . j a v a 2 s . c om*/ getMenuInflater().inflate(R.menu.activity_screen_slide, menu); menu.findItem(R.id.action_previous).setEnabled(mPager.getCurrentItem() > 0); // Add either a "next" or "finish" button to the action bar, depending on which page // is currently selected. MenuItem item = menu.add(Menu.NONE, R.id.action_next, Menu.NONE, (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? R.string.action_finish : R.string.action_next); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); item.setIcon(R.drawable.ic_menu_forward); MenuItem stepItem = menu.add(Menu.NONE, R.id.action_step_ten, Menu.NONE, step10 ? R.string.action_step_ten : R.string.action_step_one); stepItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); MenuItem turn_on_flash_Item = menu.add(Menu.NONE, R.id.action_turn_on_flash, Menu.NONE, R.string.action_turn_on_light); turn_on_flash_Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); turn_on_flash_Item.setIcon(R.drawable.ic_menu_flashlight); MenuItem filter_Item = menu.add(Menu.NONE, R.id.action_filter, Menu.NONE, R.string.filter); filter_Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); filter_Item.setIcon(R.drawable.filter); MenuItem search_Item = menu.add(Menu.NONE, R.id.action_search, Menu.NONE, R.string.search); search_Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); MenuItem addCustomer_Item = menu.add(Menu.NONE, R.id.action_new_customer, Menu.NONE, R.string.new_customer); addCustomer_Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); setTitle(); progressbar.setProgress(mPager.getCurrentItem() + 1); progressbar.setMax(mPagerAdapter.getCount()); final Handler handler = new Handler(); progressbar.setVisibility(View.VISIBLE); handler.postDelayed(new Runnable() { @Override public void run() { callCount--; if (callCount <= 0) { progressbar.setVisibility(View.GONE); } } }, 3000); callCount++; } catch (Exception ex) { ex.toString(); } return true; }
From source file:com.android.gallery3d.filtershow.FilterShowActivity.java
public void loadEditorPanel(FilterRepresentation representation, final Editor currentEditor) { if (representation.getEditorId() == ImageOnlyEditor.ID) { currentEditor.reflectCurrentFilter(); return;/*w w w . ja v a 2s .c o m*/ } final int currentId = currentEditor.getID(); Runnable showEditor = new Runnable() { @Override public void run() { EditorPanel panel = new EditorPanel(); panel.setEditor(currentId); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG)); transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG); transaction.commit(); } }; Fragment main = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG); boolean doAnimation = false; if (mShowingImageStatePanel && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { doAnimation = true; } if (doAnimation && main != null && main instanceof MainPanel) { MainPanel mainPanel = (MainPanel) main; View container = mainPanel.getView().findViewById(R.id.category_panel_container); View bottom = mainPanel.getView().findViewById(R.id.bottom_panel); int panelHeight = container.getHeight() + bottom.getHeight(); ViewPropertyAnimator anim = mainPanel.getView().animate(); anim.translationY(panelHeight).start(); final Handler handler = new Handler(); handler.postDelayed(showEditor, anim.getDuration()); } else { showEditor.run(); } }
From source file:com.simadanesh.isatis.ScreenSlideActivity.java
private void showManehMenu() { View p = findViewById(R.id.anchorer); progressbar.setVisibility(View.GONE); final PopupMenu popup = new PopupMenu(this, p); //Inflating the Popup using xml file for (ManehCode m : CommonPlace.manehCodes) { if (!m.Maneh_fldCode.equals("0")) { int cnt = ReadingListDetailDA.getInstance(this).getCount("HeaderID=? and fldManehCodeNow=?", "", new String[] { CommonPlace.currentReadingList.id + "", m.Maneh_fldCode }); popup.getMenu().add(0, Integer.parseInt(m.Maneh_fldCode), 0, m.fldTiltle + "\t" + cnt); }/* w w w . j a va2 s . c om*/ } popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { filterManeh(item.getItemId(), item.getTitle().toString()); return true; } }); final Handler handler1 = new Handler(); progressbar.setVisibility(View.GONE); //android.R.attr.progressBarStyleLarge handler1.postDelayed(new Runnable() { @Override public void run() { popup.show(); } }, 100); }
From source file:com.todoroo.astrid.activity.TaskEditFragment.java
private void loadMoreContainer() { View moreTab = (View) getView().findViewById(R.id.more_container); View commentsBar = (View) getView().findViewById(R.id.updatesFooter); long idParam = getActivity().getIntent().getLongExtra(TOKEN_ID, -1L); tabStyle = TaskEditViewPager.TAB_SHOW_ACTIVITY; if (!showEditComments) tabStyle &= ~TaskEditViewPager.TAB_SHOW_ACTIVITY; if (moreSectionHasControls) tabStyle |= TaskEditViewPager.TAB_SHOW_MORE; if (editNotes == null) { instantiateEditNotes();/*from ww w .ja va2 s . c om*/ } else { editNotes.loadViewForTaskID(idParam); } if (timerAction != null && editNotes != null) { timerAction.removeListener(editNotes); timerAction.addListener(editNotes); } if (editNotes != null) editNotes.addListener(this); if (tabStyle == 0) { return; } TaskEditViewPager adapter = new TaskEditViewPager(getActivity(), tabStyle); adapter.parent = this; mPager = (NestableViewPager) getView().findViewById(R.id.pager); mPager.setAdapter(adapter); mIndicator = (TabPageIndicator) getView().findViewById(R.id.indicator); mIndicator.setViewPager(mPager); mIndicator.setOnPageChangeListener(this); if (moreControls.getParent() != null && moreControls.getParent() != mPager) { ((ViewGroup) moreControls.getParent()).removeView(moreControls); } if (showEditComments) commentsBar.setVisibility(View.VISIBLE); moreTab.setVisibility(View.VISIBLE); setCurrentTab(TAB_VIEW_UPDATES); setPagerHeightForPosition(TAB_VIEW_UPDATES); Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { updatesChanged(); } }, 500L); }