public GoogleCardsTravelAdapter(
     FragmentActivity context, List<DashboardModel> items, FragmentManager fmManager) {
   super(context, 0, items);
   this.context = context;
   this.fmManager = fmManager;
   mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
 }
Exemple #2
0
  /**
   * Inflates a new popup window.
   *
   * @param p a point on the screen
   */
  private void showMenuPopup(Point p) {
    try {
      // Inflate the popup_layout.xml
      layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      inflateLayout();

      // Creating the PopupWindow
      popupWindow = new PopupWindow();
      popupWindow.setContentView(layout);
      popupWindow.setWidth(LinearLayout.LayoutParams.WRAP_CONTENT);
      popupWindow.setHeight(LinearLayout.LayoutParams.WRAP_CONTENT);

      // Make the window disappear when clicked outside.
      popupWindow.setTouchable(true);
      popupWindow.setFocusable(true);
      popupWindow.setOutsideTouchable(true);
      popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

      // Displaying the popup at the specified location, + offsets.
      popupWindow.showAtLocation(layout, Gravity.NO_GRAVITY, p.x, p.y);

      addListeners();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  private void hideSoftInput() {
    InputMethodManager imm =
        (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);

    View v = getCurrentFocus();
    if (v == null) return;

    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
  }
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    parentActivity = this.getActivity();
    layoutInflater =
        ((LayoutInflater) parentActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE));
    font = Typeface.createFromAsset(parentActivity.getAssets(), "Roboto-Light.ttf");
    myExperimentLoginText.setTypeface(font);
    myExperimentLoginText.setTextSize(20);
    myExperimentLoginText.setOnClickListener(
        new android.view.View.OnClickListener() {
          @Override
          public void onClick(View v) {
            User user = TavernaAndroid.getMyEUserLoggedin();
            if (user != null) {
              MessageHelper.showOptionsDialog(
                  parentActivity,
                  "Do you wish to log out ?",
                  "Attention",
                  new CallbackTask() {
                    @Override
                    public Object onTaskInProgress(Object... param) {
                      // Clear user logged-in and cookie
                      TavernaAndroid.setMyEUserLoggedin(null);
                      TavernaAndroid.setMyExperimentSessionCookies(null);
                      TavernaAndroid.setMyWorkflows(null);
                      TavernaAndroid.setFavouriteWorkflows(null);
                      clearLoginPreference();
                      parentActivity.recreate();
                      // refreshLoginState();
                      return null;
                    }

                    @Override
                    public Object onTaskComplete(Object... result) {
                      return null;
                    }
                  },
                  null);
            } else {
              ((MainPanelActivity) parentActivity).getMenu().toggle();
              Intent gotoMyexperimentLogin = new Intent(parentActivity, MyExperimentLogin.class);
              parentActivity.startActivity(gotoMyexperimentLogin);
            }
          }
        });

    // create a new AuthSession so that we can use the Dropbox API.
    AndroidAuthSession session = buildSession();
    mApi = new DropboxAPI<AndroidAuthSession>(session);
    TavernaAndroid.setmApi(mApi);
    if (dropboxLoggedIn()) {
      getDropboxAccountInfo();
    }
    authenticating = false;
  }
 @Override
 public Object getSystemService(String name) {
   if (mProxyActivity == this) {
     return super.getSystemService(name);
   } else {
     if (mProxyActivity != null) {
       return mProxyActivity.getSystemService(name);
     } else {
       return super.getSystemService(name);
     }
   }
 }
 @Override
 public void setUserVisibleHint(final boolean isVisibleToUser) {
   super.setUserVisibleHint(isVisibleToUser);
   final FragmentActivity activity = getActivity();
   if (isVisibleToUser && activity != null) {
     final NotificationManager nm =
         (NotificationManager) activity.getSystemService(Context.NOTIFICATION_SERVICE);
     for (long accountId : getAccountIds()) {
       final String tag = "messages_" + accountId;
       nm.cancel(tag, NOTIFICATION_ID_DIRECT_MESSAGES);
     }
   }
 }
 @Override
 public Object getSystemService(String name) {
   if (getCase() == null) {
     super.getSystemService(name);
   }
   Object service = super.getSystemService(name);
   if (service instanceof LayoutInflater) {
     ILayoutInflaterService layoutInflaterService =
         getCase().getService(ILayoutInflaterService.class);
     if (layoutInflaterService != null)
       return layoutInflaterService.getLayoutInflater((LayoutInflater) service);
   }
   return service;
 }
  public QuranPageWorker(FragmentActivity activity) {
    mContext = activity;
    mResources = activity.getResources();
    ImageCacheFragment fragment =
        ImageCacheFragment.getImageCacheFragment(activity.getSupportFragmentManager());
    mMemoryCache = fragment.mRetainedCache;
    if (mMemoryCache != null) {
      return;
    }

    final int memClass =
        ((ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
    final int cacheSize = 1024 * 1024 * memClass / 8;
    final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
    Log.d(
        TAG,
        "memory class: " + memClass + ", cache size: " + cacheSize + ", max memory: " + maxMemory);
    mMemoryCache =
        new LruCache<String, BitmapDrawable>(cacheSize) {
          @Override
          protected void entryRemoved(
              boolean evicted, String key, BitmapDrawable oldValue, BitmapDrawable newValue) {
            if (RecyclingBitmapDrawable.class.isInstance(oldValue)) {
              ((RecyclingBitmapDrawable) oldValue).setIsCached(false);
            }
          }

          @Override
          protected int sizeOf(String key, BitmapDrawable bitmapDrawable) {
            Bitmap bitmap = bitmapDrawable.getBitmap();
            if (Build.VERSION.SDK_INT >= 12) {
              return bitmap.getByteCount();
            }

            Log.d(
                TAG,
                "row bytes: "
                    + bitmap.getRowBytes()
                    + ", height: "
                    + bitmap.getHeight()
                    + ", "
                    + (bitmap.getRowBytes() * bitmap.getHeight()));
            return bitmap.getRowBytes() * bitmap.getHeight();
          }
        };
    fragment.mRetainedCache = mMemoryCache;

    Log.d(TAG, "initial LruCache size: " + (memClass / 8));
  }
  public FExListAdapter(FragmentActivity activity, Workout workout) {
    mActivity = activity;
    mInflater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    mTrainingEntryList = new ArrayList<TrainingEntry>();

    if (workout != null) {
      mFitnessExerciseList = workout.getFitnessExercises();
      for (FitnessExercise fEx : mFitnessExerciseList) {
        mTrainingEntryList.add(fEx.getLastTrainingEntry());
      }
    } else {
      mFitnessExerciseList = new ArrayList<FitnessExercise>();
    }
  }
  public PortalAdapter(FragmentActivity context) {
    this.context = context;
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    new InitManager(
            context,
            new Runnable() {
              @Override
              public void run() {
                configLoaded = true;
                notifyDataSetChanged();
                loadForum();
                loadTopics();
              }
            })
        .init();
  }
Exemple #11
0
  public static void hideSoftKeyboard(FragmentActivity fragmentActivity) {

    if (fragmentActivity == null) {
      return;
    }
    InputMethodManager inputMethodManager =
        (InputMethodManager) fragmentActivity.getSystemService(Activity.INPUT_METHOD_SERVICE);
    View currentFocus = fragmentActivity.getCurrentFocus();
    if (null != currentFocus) {
      inputMethodManager.hideSoftInputFromWindow(
          currentFocus.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    } else {
      inputMethodManager.hideSoftInputFromWindow(
          fragmentActivity.getWindow().getDecorView().getWindowToken(),
          InputMethodManager.HIDE_NOT_ALWAYS);
    }

    //   inputMethodManager.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
  }
  /**
   * Show Notification
   *
   * @param info
   * @see Notification#show(android.content.Context, int)
   */
  public void showNotification(String content, String apkUrl) {
    android.app.Notification noti;
    Intent myIntent = new Intent(mContext, DownloadService.class);
    myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    myIntent.putExtra(Constants.APK_DOWNLOAD_URL, apkUrl);
    PendingIntent pendingIntent =
        PendingIntent.getService(mContext, 0, myIntent, PendingIntent.FLAG_UPDATE_CURRENT);

    int smallIcon = mContext.getApplicationInfo().icon;
    noti =
        new NotificationCompat.Builder(mContext)
            .setTicker(getString(R.string.newUpdateAvailable))
            .setContentTitle(getString(R.string.newUpdateAvailable))
            .setContentText(content)
            .setSmallIcon(smallIcon)
            .setContentIntent(pendingIntent)
            .build();

    noti.flags = android.app.Notification.FLAG_AUTO_CANCEL;
    NotificationManager notificationManager =
        (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0, noti);
  }
  /**
   * Runs on the UI thread after {@link #doInBackground}. The specified result is the value returned
   * by {@link #doInBackground}.
   *
   * <p>
   *
   * <p>This method won't be invoked if the task was cancelled.
   *
   * @param result The result of the operation computed by {@link #doInBackground}.
   * @see #onPreExecute
   * @see #doInBackground
   * @see #onCancelled(Object)
   */
  @Override
  protected void onPostExecute(String result) {

    class MyLocationListener implements LocationListener {

      @Override
      public void onLocationChanged(Location location) {
        if (location != null) {

          Double latitude = location.getLatitude();
          Double longitude = location.getLongitude();

          if (googleMap != null) {
            LatLng locationOnMap = new LatLng(latitude, longitude);
            googleMap.addMarker(
                new MarkerOptions()
                    .position(locationOnMap)
                    .title("You are Here")
                    .icon(
                        BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
            // CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(locationOnMap,
            //      GoogleMapConstants.ZOOM_SCALE);
            // googleMap.animateCamera(cameraUpdate);
          }
        }
      }

      @Override
      public void onStatusChanged(String provider, int status, Bundle extras) {}

      @Override
      public void onProviderEnabled(String provider) {}

      @Override
      public void onProviderDisabled(String provider) {}
    }

    try {
      JSONArray jsonArray = new JSONArray(result);
      JSONObject jsonObject = (JSONObject) jsonArray.get(0);
      String latitudeString = (String) jsonObject.get("latitude");
      Double busLatitude = Double.parseDouble(latitudeString);
      String longitudeString = (String) jsonObject.get("longitude");
      Double busLongitude = Double.parseDouble(longitudeString);
      String username = (String) jsonObject.get("username");
      String busName = (String) jsonObject.get("busname");

      // setting the  Bus location
      LatLng busLocation = new LatLng(busLatitude, busLongitude);
      googleMap.addMarker(
          new MarkerOptions()
              .position(busLocation)
              .title(
                  " Your "
                      + busName
                      + " is Bus is Here and Its location is provided by "
                      + username)
              .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
      googleMap.getUiSettings().setZoomControlsEnabled(true);
      CameraUpdate cameraUpdate =
          CameraUpdateFactory.newLatLngZoom(busLocation, GoogleMapConstants.ZOOM_SCALE);
      googleMap.animateCamera(cameraUpdate);

      LocationManager locationManager =
          (LocationManager) fragmentActivity.getSystemService(Context.LOCATION_SERVICE);
      LocationListener locationListener = new MyLocationListener();
      locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);

    } catch (Exception e) {
      Log.e("onPostExecute", " Exception after retreiving JSON String", e);
    }
  }
 public InstantAnswersAdapter(FragmentActivity context) {
   this.context = context;
   inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
 }