/**
  * @param activity the context of the activity
  * @brief methods for showing the soft keyboard by forced
  */
 public static void showSoftKeyboard(Activity activity) {
   if (activity.getCurrentFocus() != null) {
     InputMethodManager inputMethodManager =
         (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
     inputMethodManager.showSoftInput(activity.getCurrentFocus(), 0);
   }
 }
Beispiel #2
2
 public static boolean hideSoftInput(Activity activity) {
   if (activity.getCurrentFocus() != null) {
     InputMethodManager imm =
         (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
     return imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
   }
   return false;
 }
Beispiel #3
1
 public void onClick_back(View v) {
   InputMethodManager imm =
       (InputMethodManager) actividad.getSystemService(Context.INPUT_METHOD_SERVICE);
   View foco = actividad.getCurrentFocus();
   if (foco == null || !imm.hideSoftInputFromWindow(foco.getWindowToken(), 0)) {
     AlertDialog.Builder b = new AlertDialog.Builder(this);
     b.setMessage("¿Seguro que desea salir del CheckList?");
     b.setPositiveButton(
         "SI",
         new DialogInterface.OnClickListener() {
           @Override
           public void onClick(DialogInterface dialogInterface, int i) {
             saveData();
             actividad.finish();
           }
         });
     b.setNegativeButton(
         "No",
         new DialogInterface.OnClickListener() {
           @Override
           public void onClick(DialogInterface dialogInterface, int i) {
             dialogInterface.dismiss();
           }
         });
     b.show();
   }
 }
 /**
  * @param activity the context of the activity
  * @brief methods for hiding the soft keyboard by forced
  */
 public static void hideSoftKeyboard(Activity activity) {
   if (activity.getCurrentFocus() != null) {
     InputMethodManager inputMethodManager =
         (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
     inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
   }
 }
Beispiel #5
0
 /**
  * 打开输入法面板
  *
  * @param activity
  */
 public static void showInputMethod(final Activity activity) {
   if (activity == null) return;
   InputMethodManager inputMethodManager =
       ((InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE));
   if (activity.getCurrentFocus() != null) {
     inputMethodManager.showSoftInput(activity.getCurrentFocus(), 0);
   }
 }
  public static void showSoftKeyboard(Activity activity) {
    InputMethodManager inputMethodManager =
        (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);

    if (inputMethodManager != null && activity.getCurrentFocus() != null) {
      inputMethodManager.hideSoftInputFromWindow(
          activity.getCurrentFocus().getWindowToken(), InputMethodManager.SHOW_FORCED);
    }
  }
 public static void hideKeyboard(final Activity act) {
   if (null == act) {
     return;
   }
   if (null == act.getCurrentFocus()) {
     return;
   }
   ((InputMethodManager) act.getSystemService(Context.INPUT_METHOD_SERVICE))
       .hideSoftInputFromWindow(act.getCurrentFocus().getWindowToken(), 0);
 }
Beispiel #8
0
 /** 隐藏软键盘 */
 public static void hideKeyboard(Activity context) {
   if (context.getWindow().getAttributes().softInputMode
       != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
     if (context.getCurrentFocus() != null) {
       InputMethodManager manager =
           (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
       manager.hideSoftInputFromWindow(
           context.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
     }
   }
 }
  public static void hideSoftKeyboard(Activity activity) {
    if (activity == null) {
      return;
    }
    InputMethodManager inputMethodManager =
        (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);

    if (inputMethodManager != null && activity.getCurrentFocus() != null) {

      // clear focus first (this resolves some weird issues on 2.2, 2.3 devices)
      View focusView = activity.getCurrentFocus();
      focusView.clearFocus();

      inputMethodManager.hideSoftInputFromWindow(focusView.getWindowToken(), 0);
    }
  }
 /**
  * Create the dialog and returns it as a Dialog object
  *
  * @return Dialog
  */
 public Dialog create() {
   AlertDialog.Builder builder = new AlertDialog.Builder(activity);
   builder.setTitle(R.string.weather);
   builder.setPositiveButton(R.string.ok, null);
   View view =
       activity
           .getLayoutInflater()
           .inflate(
               R.layout.dialog_weather_results, (ViewGroup) activity.getCurrentFocus(), false);
   builder.setView(view);
   builder.setView(view);
   notifyDialogData(view);
   builder.setPositiveButton(R.string.ok, null);
   /** Handle the Save Button click event * */
   builder.setNegativeButton(
       R.string.save,
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
           /** Close the dialog * */
           dialog.dismiss();
           /** process the event * */
           saveButtonClick();
         }
       });
   return builder.create();
 }
Beispiel #11
0
 /**
  * 关闭输入法
  *
  * @param act
  */
 public static void closeInputMethod(Activity act) {
   View view = act.getCurrentFocus();
   if (view != null) {
     ((InputMethodManager) act.getSystemService(Context.INPUT_METHOD_SERVICE))
         .hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
   }
 }
Beispiel #12
0
 public static void hideSoftKeyboard(Activity activity) {
   View view = activity.getCurrentFocus();
   if (view != null) {
     InputMethodManager imm =
         (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
     imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
   }
 }
Beispiel #13
0
 public static boolean showSoftInput(Activity activity) {
   View view = activity.getCurrentFocus();
   if (view != null) {
     InputMethodManager imm =
         (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
     return imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
   }
   return false;
 }
 /**
  * 动态隐藏软键盘
  *
  * @param activity activity
  */
 public static void hideSoftInput(Activity activity) {
   View view = activity.getCurrentFocus();
   if (view == null) {
     view = new View(activity);
   }
   InputMethodManager imm =
       (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
   imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
 }
 public static void hide_keyboard(Activity activity) {
   InputMethodManager inputMethodManager =
       (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
   // Find the currently focused view, so we can grab the correct window token from it.
   View view = activity.getCurrentFocus();
   // If no view currently has focus, create a new one, just so we can grab a window token from it
   if (view == null) {
     view = new View(activity);
   }
   inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
 }
Beispiel #16
0
  public static void hideSoftInput(Activity activity) {
    if (activity == null) {
      return;
    }
    View v = activity.getCurrentFocus();
    if (v == null) {
      return;
    }

    InputMethodManager inputMethodManager =
        (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
  }
Beispiel #17
0
 public static void toggleSoftKeyBoard(Activity activity, boolean hide) {
   InputMethodManager inputManager =
       (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
   View view = activity.getCurrentFocus();
   if (view == null) {
     return;
   }
   if (hide) {
     inputManager.hideSoftInputFromWindow(
         view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
   } else {
     inputManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
   }
 }
  @Override
  public void sendTextMessage() {
    viewHolder.etMsg.setText("");
    viewHolder.etMsg.clearFocus();
    View view = activity.getCurrentFocus();
    if (view != null) {
      InputMethodManager imm =
          (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }
    showFabs();

    viewHolder.rvChat.getAdapter().notifyDataSetChanged();
    viewHolder.rvChat.scrollToPosition(0);
  }
  @Override
  public Result execute(String... args) {
    if (args.length != 1) {
      return Result.failedResult("This action takes one argument");
    }

    Activity currentActivity = InstrumentationBackend.solo.getCurrentActivity();
    final View view = currentActivity.getCurrentFocus();

    if (!(view != null && view instanceof TextView)) {
      return Result.failedResult("The focused view must be an instance of TextView");
    }

    String textToEnter = args[0];

    InstrumentationBackend.solo.enterText(textToEnter);

    return Result.successResult();
  }
  @Override
  public Result execute(String... args) {
    Context context = InstrumentationBackend.instrumentation.getTargetContext();
    InputMethodManager inputMethodManager =
        (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);

    Activity activity = InstrumentationBackend.solo.getCurrentActivity();
    View view;

    view = InfoMethodUtil.tryGetServedView();

    if (view == null) {
      view = activity.getCurrentFocus();
    }

    if (view == null) {
      view = new View(activity);
    }

    inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);

    return Result.successResult();
  }
Beispiel #21
0
    @Override
    protected void onPreExecute() {
      // TODO Auto-generated method stub
      //	    	this.progressComprobarVersion.show();
      actionBar.setProgressBarVisibility(ProgressBar.VISIBLE);
      actionBar.setTitle(" Comprobando lenguajes");

      LayoutInflater inflater = activity.getLayoutInflater();
      View dialoglayout =
          inflater.inflate(R.layout.alert_loading_simple, (ViewGroup) activity.getCurrentFocus());
      mDialog = new Dialog(activity, android.R.style.Theme_Translucent_NoTitleBar);

      downloading = (ProgressBar) dialoglayout.findViewById(R.id.progressBarDownlaod);
      downloading.setMax(100);

      accion = (TextView) dialoglayout.findViewById(R.id.textViewAccion);
      accion.setText("Descargando lenguajes");

      LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
      mDialog.addContentView(dialoglayout, params);
      mDialog.show();

      super.onPreExecute();
    }
  public boolean onTouchEvent(MotionEvent ev) {
    if (!checkTransitionAnimation() && !inActionMode && !animationInProgress) {
      if (fragmentsStack.size() > 1) {
        if (ev != null
            && ev.getAction() == MotionEvent.ACTION_DOWN
            && !startedTracking
            && !maybeStartTracking) {
          BaseFragment currentFragment = fragmentsStack.get(fragmentsStack.size() - 1);
          if (!currentFragment.swipeBackEnabled) {
            return false;
          }
          startedTrackingPointerId = ev.getPointerId(0);
          maybeStartTracking = true;
          startedTrackingX = (int) ev.getX();
          startedTrackingY = (int) ev.getY();
          if (velocityTracker != null) {
            velocityTracker.clear();
          }
        } else if (ev != null
            && ev.getAction() == MotionEvent.ACTION_MOVE
            && ev.getPointerId(0) == startedTrackingPointerId) {
          if (velocityTracker == null) {
            velocityTracker = VelocityTracker.obtain();
          }
          int dx = Math.max(0, (int) (ev.getX() - startedTrackingX));
          int dy = Math.abs((int) ev.getY() - startedTrackingY);
          velocityTracker.addMovement(ev);
          if (maybeStartTracking
              && !startedTracking
              && dx >= AndroidUtilities.dp(10)
              && Math.abs(dx) / 3 > dy) {
            prepareForMoving(ev);
          } else if (startedTracking) {
            if (!beginTrackingSent) {
              if (parentActivity.getCurrentFocus() != null) {
                AndroidUtilities.hideKeyboard(parentActivity.getCurrentFocus());
              }
              BaseFragment currentFragment = fragmentsStack.get(fragmentsStack.size() - 1);
              currentFragment.onBeginSlide();
              beginTrackingSent = true;
            }
            ViewProxy.setTranslationX(containerView, dx);
            setInnerTranslationX(dx);
          }
        } else if (ev != null
            && ev.getPointerId(0) == startedTrackingPointerId
            && (ev.getAction() == MotionEvent.ACTION_CANCEL
                || ev.getAction() == MotionEvent.ACTION_UP
                || ev.getAction() == MotionEvent.ACTION_POINTER_UP)) {
          if (velocityTracker == null) {
            velocityTracker = VelocityTracker.obtain();
          }
          velocityTracker.computeCurrentVelocity(1000);
          if (!startedTracking) {
            float velX = velocityTracker.getXVelocity();
            float velY = velocityTracker.getYVelocity();
            if (velX >= 3500 && velX > velY) {
              prepareForMoving(ev);
              if (!beginTrackingSent) {
                if (((Activity) getContext()).getCurrentFocus() != null) {
                  AndroidUtilities.hideKeyboard(((Activity) getContext()).getCurrentFocus());
                }
                beginTrackingSent = true;
              }
            }
          }
          if (startedTracking) {
            float x = ViewProxy.getX(containerView);
            AnimatorSetProxy animatorSet = new AnimatorSetProxy();
            float velX = velocityTracker.getXVelocity();
            float velY = velocityTracker.getYVelocity();
            final boolean backAnimation =
                x < containerView.getMeasuredWidth() / 3.0f && (velX < 3500 || velX < velY);
            float distToMove = 0;
            if (!backAnimation) {
              distToMove = containerView.getMeasuredWidth() - x;
              animatorSet.playTogether(
                  ObjectAnimatorProxy.ofFloat(containerView, "x", containerView.getMeasuredWidth()),
                  ObjectAnimatorProxy.ofFloat(
                      this, "innerTranslationX", (float) containerView.getMeasuredWidth()));
            } else {
              distToMove = x;
              animatorSet.playTogether(
                  ObjectAnimatorProxy.ofFloat(containerView, "x", 0),
                  ObjectAnimatorProxy.ofFloat(this, "innerTranslationX", 0.0f));
            }

            animatorSet.setDuration(
                Math.max((int) (200.0f / containerView.getMeasuredWidth() * distToMove), 50));
            animatorSet.addListener(
                new AnimatorListenerAdapterProxy() {
                  @Override
                  public void onAnimationEnd(Object animator) {
                    onSlideAnimationEnd(backAnimation);
                  }

                  @Override
                  public void onAnimationCancel(Object animator) {
                    onSlideAnimationEnd(backAnimation);
                  }
                });
            animatorSet.start();
            animationInProgress = true;
          } else {
            maybeStartTracking = false;
            startedTracking = false;
          }
          if (velocityTracker != null) {
            velocityTracker.recycle();
            velocityTracker = null;
          }
        } else if (ev == null) {
          maybeStartTracking = false;
          startedTracking = false;
          if (velocityTracker != null) {
            velocityTracker.recycle();
            velocityTracker = null;
          }
        }
      }
      return startedTracking;
    }
    return false;
  }
  public void closeLastFragment(boolean animated) {
    if (delegate != null && !delegate.needCloseLastFragment(this)
        || checkTransitionAnimation()
        || fragmentsStack.isEmpty()) {
      return;
    }
    if (parentActivity.getCurrentFocus() != null) {
      AndroidUtilities.hideKeyboard(parentActivity.getCurrentFocus());
    }
    setInnerTranslationX(0);
    boolean needAnimation =
        Build.VERSION.SDK_INT > 10
            && animated
            && parentActivity
                .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE)
                .getBoolean("view_animations", true);
    final BaseFragment currentFragment = fragmentsStack.get(fragmentsStack.size() - 1);
    BaseFragment previousFragment = null;
    if (fragmentsStack.size() > 1) {
      previousFragment = fragmentsStack.get(fragmentsStack.size() - 2);
    }

    if (previousFragment != null) {
      LinearLayoutContainer temp = containerView;
      containerView = containerViewBack;
      containerViewBack = temp;
      containerView.setVisibility(View.VISIBLE);

      previousFragment.setParentLayout(this);
      View fragmentView = previousFragment.createView(parentActivity.getLayoutInflater());
      if (previousFragment.needAddActionBar() && previousFragment.actionBar != null) {
        if (removeActionBarExtraHeight) {
          previousFragment.actionBar.setOccupyStatusBar(false);
        }
        ViewGroup parent = (ViewGroup) previousFragment.actionBar.getParent();
        if (parent != null) {
          parent.removeView(previousFragment.actionBar);
        }
        containerView.addView(previousFragment.actionBar);
        previousFragment.actionBar.setTitleOverlayText(titleOverlayText);
      }
      containerView.addView(fragmentView);
      ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams();
      layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
      layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
      fragmentView.setLayoutParams(layoutParams);
      previousFragment.onResume();
      currentActionBar = previousFragment.actionBar;
      if (fragmentView.getBackground() == null) {
        fragmentView.setBackgroundColor(0xffffffff);
      }

      if (!needAnimation) {
        closeLastFragmentInternalRemoveOld(currentFragment);
      }

      if (needAnimation) {
        transitionAnimationStartTime = System.currentTimeMillis();
        transitionAnimationInProgress = true;
        onCloseAnimationEndRunnable =
            new Runnable() {
              @Override
              public void run() {
                closeLastFragmentInternalRemoveOld(currentFragment);
                ViewProxy.setTranslationX(containerViewBack, 0);
              }
            };

        currentAnimation = new AnimatorSetProxy();
        currentAnimation.playTogether(
            ObjectAnimatorProxy.ofFloat(containerViewBack, "alpha", 1.0f, 0.0f),
            ObjectAnimatorProxy.ofFloat(
                containerViewBack, "translationX", 0, AndroidUtilities.dp(48)));
        currentAnimation.setInterpolator(new DecelerateInterpolator(1.5f));
        currentAnimation.setDuration(200);
        currentAnimation.addListener(
            new AnimatorListenerAdapterProxy() {
              @Override
              public void onAnimationStart(Object animation) {
                transitionAnimationStartTime = System.currentTimeMillis();
              }

              @Override
              public void onAnimationEnd(Object animation) {
                onAnimationEndCheck(false);
              }

              @Override
              public void onAnimationCancel(Object animation) {
                onAnimationEndCheck(false);
              }
            });
        currentAnimation.start();
      }
    } else {
      if (useAlphaAnimations) {
        transitionAnimationStartTime = System.currentTimeMillis();
        transitionAnimationInProgress = true;

        onCloseAnimationEndRunnable =
            new Runnable() {
              @Override
              public void run() {
                removeFragmentFromStack(currentFragment);
                setVisibility(GONE);
                if (backgroundView != null) {
                  backgroundView.setVisibility(GONE);
                }
                if (drawerLayoutContainer != null) {
                  drawerLayoutContainer.setAllowOpenDrawer(true);
                }
              }
            };

        ArrayList<Object> animators = new ArrayList<>();
        animators.add(ObjectAnimatorProxy.ofFloat(this, "alpha", 1.0f, 0.0f));
        if (backgroundView != null) {
          animators.add(ObjectAnimatorProxy.ofFloat(backgroundView, "alpha", 1.0f, 0.0f));
        }

        currentAnimation = new AnimatorSetProxy();
        currentAnimation.playTogether(animators);
        currentAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
        currentAnimation.setDuration(200);
        currentAnimation.addListener(
            new AnimatorListenerAdapterProxy() {
              @Override
              public void onAnimationStart(Object animation) {
                transitionAnimationStartTime = System.currentTimeMillis();
              }

              @Override
              public void onAnimationEnd(Object animation) {
                onAnimationEndCheck(false);
              }

              @Override
              public void onAnimationCancel(Object animation) {
                onAnimationEndCheck(false);
              }
            });
        currentAnimation.start();
      } else {
        removeFragmentFromStack(currentFragment);
        setVisibility(GONE);
        if (backgroundView != null) {
          backgroundView.setVisibility(GONE);
        }
      }
    }
  }
Beispiel #24
0
 /**
  * Hides the keyboard. Note that both the context and the view must be non-null.
  *
  * @param context
  * @param view used to get the window token
  */
 public static void hide(Activity context) {
   hide(context, context.getCurrentFocus());
 }
Beispiel #25
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.changeAlliance) {
      isRed = !isRed;
      SuperScoutApplication.isRed = true;
      commitSharedPreferences();
      updateUI();
    }
    if (id == R.id.scout) {
      if (!FirebaseLists.matchesList.getKeys().contains(matchNumber.toString())) {
        Toast.makeText(context, "This Match Does Not Exist!", Toast.LENGTH_LONG).show();
        disenableEditTextEditing();
      } else {
        if (numberOfMatch.getText().toString().equals("")) {
          Toast.makeText(context, "Input match name!", Toast.LENGTH_SHORT).show();
        } else if (teamNumberOne.getText().toString().equals("")) {
          Toast.makeText(context, "Input team one number!", Toast.LENGTH_SHORT).show();
        } else if (teamNumberTwo.getText().toString().equals("")) {
          Toast.makeText(context, "Input team two number!", Toast.LENGTH_SHORT).show();
        } else if (teamNumberThree.getText().toString().equals("")) {
          Toast.makeText(context, "Input team three number!", Toast.LENGTH_SHORT).show();
        } else if (teamNumberOne.getText().toString().equals("Not Available")) {
          Toast.makeText(context, "This Match Does Not Exist!", Toast.LENGTH_SHORT).show();
        } else {
          commitSharedPreferences();
          Intent intent = new Intent(context, FieldSetUp.class);
          intent.putExtra("matchNumber", numberOfMatch.getText().toString());
          intent.putExtra("teamNumberOne", teamNumberOne.getText().toString());
          intent.putExtra("teamNumberTwo", teamNumberTwo.getText().toString());
          intent.putExtra("teamNumberThree", teamNumberThree.getText().toString());
          intent.putExtra("alliance", alliance.getText().toString());
          intent.putExtra("dataBaseUrl", dataBaseUrl);
          intent.putExtra("mute", isMute);
          intent.putExtra("allianceColor", isRed);
          Log.e("start alliance", alliance.getText().toString());
          startActivity(intent);
        }
      }

    } else if (id == R.id.action_override) {
      if (item.getTitle().toString().equals("Override Match and Team Number")) {
        enableEditTextEditing();
        item.setTitle("Automate");
      } else if (item.getTitle().toString().equals("Automate")) {
        View view = context.getCurrentFocus();
        updateUI();
        commitSharedPreferences();
        disenableEditTextEditing();
        InputMethodManager imm =
            (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
        item.setTitle("Override Match and Team Number");
      }
    }
    return super.onOptionsItemSelected(item);
  }
Beispiel #26
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_event_map, container, false);
    if (activity != null) {
      InputMethodManager input =
          (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
      if (activity.getCurrentFocus() != null)
        input.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
    }
    centres = new ArrayList<Centers>();

    title = (TextView) rootView.findViewById(R.id.tit);
    Log.e("here", "in map");

    l = (LinearLayout) rootView.findViewById(R.id.con);
    this.mapFragment =
        (com.google.android.gms.maps.MapFragment)
            activity.getFragmentManager().findFragmentById(R.id.map);
    map = mapFragment.getMap();
    final CameraUpdate center = CameraUpdateFactory.newLatLng(new LatLng(21, 78));
    CameraUpdate zoom = CameraUpdateFactory.zoomTo(15);

    if (map != null) {
      map.moveCamera(center);
      map.animateCamera(zoom);
    }

    map.setOnMarkerClickListener(
        new GoogleMap.OnMarkerClickListener() {
          @Override
          public boolean onMarkerClick(Marker marker) {

            l.setVisibility(View.VISIBLE);
            int i = 0;
            for (i = 0; i < centres.size(); i++) {
              Centers o = centres.get(i);
              if (o.title.equals(marker.getTitle())) {
                index = i;
                break;
              }
            }

            title = (TextView) rootView.findViewById(R.id.tit);
            if (centres.get(index).title != null && !centres.get(index).title.equals("null"))
              title.setText(centres.get(index).title);
            title = (TextView) rootView.findViewById(R.id.add);
            if (centres.get(index).add != null && !centres.get(index).add.equals("null"))
              title.setText(centres.get(index).add);
            title = (TextView) rootView.findViewById(R.id.web);
            if (centres.get(index).web != null && !centres.get(index).web.equals("null"))
              title.setText(centres.get(index).web);
            title.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    Intent i = new Intent(Intent.ACTION_VIEW);
                    i.setData(Uri.parse(centres.get(index).web));
                    startActivity(i);
                  }
                });
            title = (TextView) rootView.findViewById(R.id.email);
            if (centres.get(index).sontact != null && !centres.get(index).sontact.equals("null"))
              title.setText(centres.get(index).sontact);

            title.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    Intent intent = new Intent(Intent.ACTION_SEND);
                    intent.setType("text/html");
                    intent.putExtra(Intent.EXTRA_EMAIL, centres.get(index).sontact);
                    startActivity(Intent.createChooser(intent, "Send Email"));
                  }
                });

            title = (TextView) rootView.findViewById(R.id.phone);
            if (centres.get(index).phone != null && !centres.get(index).phone.equals("null"))
              title.setText(centres.get(index).phone);
            title.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    Intent intent = new Intent(Intent.ACTION_DIAL);
                    intent.setData(Uri.parse("tel:" + centres.get(index).phone));
                    startActivity(intent);
                  }
                });

            return false;
          }
        });

    GPSTracker tracker = new GPSTracker(activity);
    if (tracker.canGetLocation() == false) {
      tracker.showSettingsAlert();

    } else {
      latitude = tracker.getLatitude();
      longitude = tracker.getLongitude();
    }

    new Down().execute();

    return rootView;
  }
Beispiel #27
0
 public static boolean hideKeyboard(Activity ctx) {
   InputMethodManager imm =
       (InputMethodManager) ctx.getSystemService(Context.INPUT_METHOD_SERVICE);
   View curFocus = ctx.getCurrentFocus();
   return curFocus != null && imm.hideSoftInputFromWindow(curFocus.getWindowToken(), 0);
 }
  public boolean presentFragment(
      final BaseFragment fragment,
      final boolean removeLast,
      boolean forceWithoutAnimation,
      boolean check) {
    if (checkTransitionAnimation()
        || delegate != null
            && check
            && !delegate.needPresentFragment(fragment, removeLast, forceWithoutAnimation, this)
        || !fragment.onFragmentCreate()) {
      return false;
    }
    if (parentActivity.getCurrentFocus() != null) {
      AndroidUtilities.hideKeyboard(parentActivity.getCurrentFocus());
      NotificationCenter.getInstance().postNotificationName(NotificationCenter.hideEmojiKeyboard);
    }
    boolean needAnimation =
        Build.VERSION.SDK_INT > 10
            && !forceWithoutAnimation
            && parentActivity
                .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE)
                .getBoolean("view_animations", true);

    final BaseFragment currentFragment =
        !fragmentsStack.isEmpty() ? fragmentsStack.get(fragmentsStack.size() - 1) : null;

    fragment.setParentLayout(this);
    View fragmentView = fragment.createView(parentActivity.getLayoutInflater());
    if (fragment.needAddActionBar() && fragment.actionBar != null) {
      if (removeActionBarExtraHeight) {
        fragment.actionBar.setOccupyStatusBar(false);
      }
      ViewGroup parent = (ViewGroup) fragment.actionBar.getParent();
      if (parent != null) {
        parent.removeView(fragment.actionBar);
      }
      containerViewBack.addView(fragment.actionBar);
      fragment.actionBar.setTitleOverlayText(titleOverlayText);
    }

    containerViewBack.addView(fragmentView);
    ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams();
    layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
    layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
    fragmentView.setLayoutParams(layoutParams);
    fragmentsStack.add(fragment);
    fragment.onResume();
    currentActionBar = fragment.actionBar;
    if (fragmentView.getBackground() == null) {
      fragmentView.setBackgroundColor(0xffffffff);
    }

    LinearLayoutContainer temp = containerView;
    containerView = containerViewBack;
    containerViewBack = temp;
    containerView.setVisibility(View.VISIBLE);
    setInnerTranslationX(0);

    bringChildToFront(containerView);

    if (!needAnimation) {
      presentFragmentInternalRemoveOld(removeLast, currentFragment);
      if (backgroundView != null) {
        backgroundView.setVisibility(VISIBLE);
      }
    }

    if (needAnimation) {
      if (useAlphaAnimations && fragmentsStack.size() == 1) {
        presentFragmentInternalRemoveOld(removeLast, currentFragment);

        ArrayList<Object> animators = new ArrayList<>();
        animators.add(ObjectAnimatorProxy.ofFloat(this, "alpha", 0.0f, 1.0f));
        if (backgroundView != null) {
          backgroundView.setVisibility(VISIBLE);
          animators.add(ObjectAnimatorProxy.ofFloat(backgroundView, "alpha", 0.0f, 1.0f));
        }

        currentAnimation = new AnimatorSetProxy();
        currentAnimation.playTogether(animators);
        currentAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
        currentAnimation.setDuration(200);
        currentAnimation.addListener(
            new AnimatorListenerAdapterProxy() {
              @Override
              public void onAnimationEnd(Object animation) {
                onAnimationEndCheck(false);
              }

              @Override
              public void onAnimationCancel(Object animation) {
                onAnimationEndCheck(false);
              }
            });
        currentAnimation.start();
      } else {
        transitionAnimationStartTime = System.currentTimeMillis();
        transitionAnimationInProgress = true;
        onOpenAnimationEndRunnable =
            new Runnable() {
              @Override
              public void run() {
                presentFragmentInternalRemoveOld(removeLast, currentFragment);
                fragment.onOpenAnimationEnd();
                ViewProxy.setTranslationX(containerView, 0);
              }
            };
        ViewProxy.setAlpha(containerView, 0.0f);
        ViewProxy.setTranslationX(containerView, 48.0f);
        currentAnimation = new AnimatorSetProxy();
        currentAnimation.playTogether(
            ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f, 1.0f),
            ObjectAnimatorProxy.ofFloat(containerView, "translationX", AndroidUtilities.dp(48), 0));
        currentAnimation.setInterpolator(new DecelerateInterpolator(1.5f));
        currentAnimation.setDuration(200);
        currentAnimation.addListener(
            new AnimatorListenerAdapterProxy() {
              @Override
              public void onAnimationStart(Object animation) {
                transitionAnimationStartTime = System.currentTimeMillis();
              }

              @Override
              public void onAnimationEnd(Object animation) {
                onAnimationEndCheck(false);
              }

              @Override
              public void onAnimationCancel(Object animation) {
                onAnimationEndCheck(false);
              }
            });
        currentAnimation.start();
      }
    } else {
      if (backgroundView != null) {
        ViewProxy.setAlpha(backgroundView, 1.0f);
        backgroundView.setVisibility(VISIBLE);
      }
      fragment.onOpenAnimationEnd();
    }
    return true;
  }
Beispiel #29
0
 /**
  * 隐藏系统键盘 <br>
  * <b>警告</b> 必须是确定键盘显示时才能调用
  */
 public static void hideKeyBoard(Activity aty) {
   ((InputMethodManager) aty.getSystemService(Context.INPUT_METHOD_SERVICE))
       .hideSoftInputFromWindow(
           aty.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
 }