/**
  * @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);
   }
 }
  /**
   * @info Γίνεται έλεγχος για το αν υπάρχει σύνδεση της συσκευής μας με το internet(wifi ή 3G),
   *     καθώς και αν το gps είναι ανοικτό.
   * @details Χρησιμοποιούμε τις ενσωματωμένες κλάσεις του android
   *     (LocationManager,ConnectivityManager), για να ελέγξουμε αν υπάρχει ενεργή συνδεσιμότητα
   * @return true : Αν είναι ανοικτό το GPS και έχουμε πρόσβαση στο internet false : Αν δεν ισχύει
   *     έστω και ένα από τα παραπάνω
   */
  private boolean isConnectingToInternet(Activity activContext) {

    try {
      LocationManager GpsSservice =
          (LocationManager) activContext.getSystemService(Context.LOCATION_SERVICE);
      ConnectivityManager connManager =
          (ConnectivityManager) activContext.getSystemService(Context.CONNECTIVITY_SERVICE);
      boolean GpsEnabled = GpsSservice.isProviderEnabled(LocationManager.GPS_PROVIDER);
      NetworkInfo info = connManager.getActiveNetworkInfo();

      if (!GpsEnabled) {

        return false;
      } else if (info.getState() != NetworkInfo.State.CONNECTED) {

        return false;
      }

    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }

    return true;
  }
 @Override
 public void onCreatePreferences(Bundle bundle, String s) {
   Activity activity = getActivity();
   PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(activity);
   screen.setTitle(activity.getString(R.string.available_virtual_keyboard_category));
   setPreferenceScreen(screen);
   mInputMethodSettingValues = InputMethodSettingValuesWrapper.getInstance(activity);
   mImm = activity.getSystemService(InputMethodManager.class);
   mDpm = activity.getSystemService(DevicePolicyManager.class);
 }
  @Override
  public void onAttach(final Activity activity) {
    super.onAttach(activity);

    this.activity = (AbstractBindServiceActivity) activity;
    this.application = (WalletApplication) activity.getApplication();
    this.config = application.getConfiguration();
    this.wallet = application.getWallet();
    this.loaderManager = getLoaderManager();
    this.nfcManager = (NfcManager) activity.getSystemService(Context.NFC_SERVICE);
    this.clipboardManager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
    this.bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
  }
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
  private void showJellyBean() {
    NotificationCompat.Builder mBuilder =
        new NotificationCompat.Builder(this.activity)
            .setSmallIcon(R.drawable.ic_launcher)
            .setContentTitle(this.title)
            .setContentText(this.text);

    // Creates an explicit intent for an Activity in your app
    Intent resultIntent = new Intent(activity, activity.getClass());

    // The stack builder object will contain an artificial back stack for the
    // started Activity.
    // This ensures that navigating backward from the Activity leads out of
    // your application to the Home screen.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(activity);

    // Adds the back stack for the Intent (but not the Intent itself)
    stackBuilder.addParentStack(activity.getClass());

    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent =
        stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(resultPendingIntent);
    NotificationManager mNotificationManager =
        (NotificationManager) activity.getSystemService(Context.NOTIFICATION_SERVICE);

    // mId allows you to update the notification later on.
    mNotificationManager.notify(this.id, mBuilder.build());
  }
Exemple #6
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();
   }
 }
  @Override
  public View getView(final int position, View convertView, final ViewGroup parent) {
    final ViewHolder viewHolder;

    if (convertView == null) {

      LayoutInflater vi = (LayoutInflater) base.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      convertView = vi.inflate(R.layout.item_reminder, parent, false);

      viewHolder = new ViewHolder();
      convertView.setTag(viewHolder);

      viewHolder.title = (TextView) convertView.findViewById(R.id.textViewReminderTitle);
      viewHolder.text = (TextView) convertView.findViewById(R.id.textViewReminderText);
      viewHolder.time = (TextView) convertView.findViewById(R.id.textViewReminderTime);
    } else {
      viewHolder = (ViewHolder) convertView.getTag();
    }

    String s = reminderList.get(position);

    String[] tokens = s.split(",");

    viewHolder.index = position;
    viewHolder.title.setText(tokens[1]);
    viewHolder.text.setText(tokens[2]);
    viewHolder.time.setText(tokens[3]);

    return convertView;
  }
 @Override
 protected void onPostExecute(String ayah) {
   Activity activity = getActivity();
   if (ayah != null && activity != null) {
     ayah =
         "("
             + ayah
             + ")"
             + " "
             + "["
             + QuranInfo.getSuraName(activity, this.sura, true)
             + " : "
             + this.ayah
             + "]"
             + activity.getString(R.string.via_string);
     if (copy) {
       ClipboardManager cm =
           (ClipboardManager) activity.getSystemService(Activity.CLIPBOARD_SERVICE);
       cm.setText(ayah);
       Toast.makeText(
               activity, activity.getString(R.string.ayah_copied_popup), Toast.LENGTH_SHORT)
           .show();
     } else {
       final Intent intent = new Intent(Intent.ACTION_SEND);
       intent.setType("text/plain");
       intent.putExtra(Intent.EXTRA_TEXT, ayah);
       startActivity(Intent.createChooser(intent, activity.getString(R.string.share_ayah)));
     }
   }
   mCurrentTask = null;
 }
  @SuppressWarnings("rawtypes")
  public SeasonAdapter(Context context) {
    activity = (Activity) context;
    inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    imageLoader = ImageLoader.getInstance();
    dbAdapter = new DatabaseAdapter(context);

    episodes = new ArrayList<Episode>();
    watched = new TreeSet();

    optionsWithDelay =
        new DisplayImageOptions.Builder()
            .showStubImage(R.drawable.stub_land)
            .showImageForEmptyUri(R.drawable.stub_land_not_found)
            .showImageOnFail(R.drawable.stub_land_not_found)
            .cacheInMemory(true)
            .cacheOnDisc(true)
            .displayer(new FadeInBitmapDisplayer(1000))
            .build();

    optionsWithoutDelay =
        new DisplayImageOptions.Builder()
            .showStubImage(R.drawable.stub_land)
            .showImageForEmptyUri(R.drawable.stub_land_not_found)
            .showImageOnFail(R.drawable.stub_land_not_found)
            .cacheInMemory(true)
            .cacheOnDisc(true)
            .build();
  }
  public Bearings(final Activity a) {
    sensorManager = (SensorManager) a.getSystemService(Context.SENSOR_SERVICE);

    // If cache not created, create it!
    if (bitmapsRotated.isEmpty()) {
      final Bitmap bearingBitmap =
          BitmapFactory.decodeResource(a.getResources(), R.drawable.bearing);

      if (bearingBitmap != null) {
        final Canvas bearingCanvas = new Canvas();
        final Paint bearingPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
        for (int i = 0; i < N_OF_CACHE_BITMAPS; i++) {
          final Bitmap b =
              Bitmap.createBitmap(
                  bearingBitmap.getWidth(), bearingBitmap.getHeight(), Bitmap.Config.ARGB_8888);

          final float direction = DEGREES_PER_BITMAP * i - 180;
          bearingCanvas.setBitmap(b);
          bearingCanvas.rotate(
              direction, bearingBitmap.getWidth() / 2, bearingBitmap.getHeight() / 2);
          bearingCanvas.drawBitmap(bearingBitmap, 0, 0, bearingPaint);
          bearingCanvas.rotate(
              -direction, bearingBitmap.getWidth() / 2, bearingBitmap.getHeight() / 2);

          bitmapsRotated.add(b);
        }
      }
    }
  }
 public LazyAdapterMainList(
     Activity a,
     ArrayList<String> name,
     ArrayList<String> dis1,
     ArrayList<String> image,
     ArrayList<String> online_image1,
     ArrayList<String> address1,
     ArrayList<String> icon_image1) {
   activity = a;
   title = new ArrayList<String>();
   distance = new ArrayList<String>();
   image_rating = new ArrayList<String>();
   online_image = new ArrayList<String>();
   address = new ArrayList<String>();
   icon_image = new ArrayList<String>();
   title = name;
   distance = dis1;
   image_rating = image;
   address = address1;
   icon_image = icon_image1;
   this.online_image = online_image1;
   inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   imageLoader = new ImageLoader(activity.getApplicationContext());
   size = title.size();
 }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View vi = convertView;

    if (convertView == null) {
      LayoutInflater inflater =
          (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      vi = inflater.inflate(R.layout.item_invitados_list, null);
    }

    GraphUser item = items.get(position);

    ProfilePictureView foto = (ProfilePictureView) vi.findViewById(R.id.fotoPerfil);
    foto.setProfileId(item.getId());

    TextView nombre = (TextView) vi.findViewById(R.id.nombrePerfil);
    nombre.setText(item.getName());

    ImageButton eliminar = (ImageButton) vi.findViewById(R.id.eliminarInvitado);
    // Usamos el SETTAG y despues el GETTAG para saber que botón ha sido pulsado de todos los items
    // que son visibles, y así poder saber que item borrar.
    eliminar.setTag(position);
    eliminar.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (view.getTag() instanceof Integer) {
              deleteItem(((Integer) view.getTag()));
              notifyDataSetChanged();
            }
          }
        });

    return vi;
  }
 @Override
 public void onActivityCreated(android.os.Bundle savedInstanceState) {
   super.onActivityCreated(savedInstanceState);
   this.getView().findViewById(R.id.editProgram).setOnClickListener(this);
   this.getView().findViewById(R.id.startProgram).setOnClickListener(this);
   btnHelpAbout = (Button) this.getView().findViewById(R.id.HelpAbout);
   btnHelpAbout.setOnClickListener(this);
   this.getView().findViewById(R.id.prefs).setOnClickListener(this);
   mLayout = (DepthLinearLayout) getView().findViewById(R.id.main_linear_layout);
   mLayout.getBackground().setDither(true);
   Activity activity = getActivity();
   mSensorManager = (SensorManager) activity.getSystemService(Context.SENSOR_SERVICE);
   mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
   display =
       ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
 };
  @Override
  public Object instantiateItem(ViewGroup container, int position) {
    TouchImageView imgDisplay;
    Button btnClose;

    inflater = (LayoutInflater) _activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View viewLayout = inflater.inflate(R.layout.layout_fullscreen_image, container, false);

    imgDisplay = (TouchImageView) viewLayout.findViewById(R.id.imgDisplay);
    btnClose = (Button) viewLayout.findViewById(R.id.btnClose);

    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inPreferredConfig = Bitmap.Config.ARGB_8888;
    Bitmap bitmap = BitmapFactory.decodeFile(_imagePaths.get(position), options);
    imgDisplay.setImageBitmap(bitmap);

    // close button click event
    btnClose.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            _activity.finish();
          }
        });

    ((ViewPager) container).addView(viewLayout);

    return viewLayout;
  }
 public ListAdapter(
     Activity context, ArrayList<FileData> filedata, BookShelfActivity lv_activity) {
   super(context, 0, filedata);
   inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   this.context = context;
   this.lv_activity = lv_activity;
 }
  public SelectCourseAdapter(Activity activty, ArrayList arrayList, Resources resource) {
    this.activity = activty;
    this.arrayList = arrayList;
    this.resource = resource;

    inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  }
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {

    if (inflater == null)
      inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (convertView == null)
      convertView = inflater.inflate(R.layout.dialog_offers_filter_row, null);

    final TextView title = (TextView) convertView.findViewById(R.id.filterText);

    // thumbNail.setImageUrl(m.getThumbnailUrl(), imageLoader);

    // title
    title.setText(movieItems.get(position));
    // title.setTag(m.getId());

    // rating
    // rating.setText("Quantity: " + String.valueOf(m.getRating()));

    // genre
    /* String genreStr = "";
    for (String str : m.getGenre()) {
        genreStr += str + ", ";
    }
    genreStr = genreStr.length() > 0 ? genreStr.substring(0,
            genreStr.length() - 2) : genreStr;
    genre.setText(genreStr);

    // release year
    year.setText(String.valueOf(m.getYear()));*/

    return convertView;
  }
Exemple #18
0
 public SongAdapter(Activity activity) {
   this.activity = activity;
   mInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   mImageViewLayoutParams =
       new RelativeLayout.LayoutParams(
           ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
 }
 /**
  * Show soft keyboard (if no hardware keyboard).
  *
  * @param context the context
  * @param view the focused view
  */
 public static void showKeyboard(Activity context, View view) {
   InputMethodManager imm =
       (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
   if (imm != null) {
     imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
   }
 }
  public kehu_gengxinshijianPopWindow(final Activity context) {
    this.context = context;
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    conentView = inflater.inflate(R.layout.crm_kehu_gengxinshijian, null);
    int h = context.getWindowManager().getDefaultDisplay().getHeight();
    int w = context.getWindowManager().getDefaultDisplay().getWidth();
    // 设置SelectPicPopupWindow的View
    this.setContentView(conentView);
    // 设置SelectPicPopupWindow弹出窗体的宽
    // this.setWidth(w / 2 + 50);
    this.setWidth(w / 2);
    // 设置SelectPicPopupWindow弹出窗体的高
    this.setHeight(LayoutParams.WRAP_CONTENT);
    // 设置SelectPicPopupWindow弹出窗体可点击
    this.setFocusable(true);
    this.setOutsideTouchable(true);
    // 刷新状态
    this.update();
    // 实例化一个ColorDrawable颜色为半透明
    ColorDrawable dw = new ColorDrawable(0000000000);
    // 点back键和其他地方使其消失,设置了这个才能触发OnDismisslistener ,设置其他控件变化等操作
    this.setBackgroundDrawable(dw);
    // mPopupWindow.setAnimationStyle(android.R.style.Animation_Dialog);
    // 设置SelectPicPopupWindow弹出窗体动画效果

    // this.setAnimationStyle(R.style.AnimationPreview);
    l1 = (LinearLayout) conentView.findViewById(R.id.l1);
    l2 = (LinearLayout) conentView.findViewById(R.id.l2);
    l3 = (LinearLayout) conentView.findViewById(R.id.l3);
    l1.setOnTouchListener(this);
    l2.setOnTouchListener(this);
    l3.setOnTouchListener(this);
  }
 /**
  * Hide soft keyboard (if no hardware keyboard).
  *
  * @param context the context
  * @param view the focused view
  */
 public static void hideKeyboard(Activity context, View view) {
   InputMethodManager imm =
       (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
   if (imm != null) {
     imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
   }
 }
  public DialogOnItemClickListener(Activity actv, Dialog dlg) {
    //
    this.actv = actv;
    this.dlg = dlg;

    vib = (Vibrator) actv.getSystemService(Context.VIBRATOR_SERVICE);
  } // public DialogOnItemClickListener(Activity actv, Dialog dlg)
 /**
  * @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);
   }
 }
 public WiFiBroadcastReceiver(Activity activity, SectionsPagerAdapter mSectionsPagerAdapter) {
   this.activity = activity;
   this.mSectionsPagerAdapter = mSectionsPagerAdapter;
   WifiManager mWifiManager = (WifiManager) activity.getSystemService(Context.WIFI_SERVICE);
   activity.registerReceiver(this, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
   mWifiManager.startScan();
 }
  public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;
    if (v == null) {
      LayoutInflater vi =
          (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      v = vi.inflate(R.layout.devicelistrow, null);
    }
    WifiP2pDevice device = peers.get(position);
    if (device != null) {
      TextView deviceName = (TextView) v.findViewById(R.id.deviceName);
      TextView deviceAddress = (TextView) v.findViewById(R.id.deviceAddress);
      TextView deviceStatus = (TextView) v.findViewById(R.id.deviceStatus);
      if (deviceName != null) {
        deviceName.setText(device.deviceName);
      }
      if (deviceAddress != null) {
        deviceAddress.setText(device.deviceAddress);
      }
      if (deviceStatus != null) {
        deviceStatus.setText(getDeviceStatus(device.status));
      }
    }

    return v;
  }
Exemple #26
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);
   }
 }
  @Override
  public void onReceive(Context context, Intent intent) {
    int extraWifiState =
        intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_UNKNOWN);

    switch (extraWifiState) {
      case WifiManager.WIFI_STATE_ENABLED:
        Toast.makeText(act, "Wifi Habilitada", Toast.LENGTH_SHORT);

        ConnectivityManager conMan =
            (ConnectivityManager) act.getSystemService(Context.CONNECTIVITY_SERVICE);
        while (conMan.getActiveNetworkInfo() == null
            || conMan.getActiveNetworkInfo().getState() != NetworkInfo.State.CONNECTED) {
          try {
            Thread.sleep(2000);
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
        }
        Toast.makeText(act, "Wifi Conectada", Toast.LENGTH_SHORT);
        break;

      case WifiManager.WIFI_STATE_DISABLED:
        alertDialog.show();
        Log.d("AlertDialog", "un dialogo");
        break;
    }
  }
 @Override
 public void onAttach(Activity activity) {
   super.onAttach(activity);
   parseIntent(activity.getIntent());
   downLoadHelper = DownLoadHelper.getInstance(activity.getApplicationContext());
   dm = (DownloadManager) activity.getSystemService(Context.DOWNLOAD_SERVICE);
 }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    if (inflater == null)
      inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (convertView == null) convertView = inflater.inflate(R.layout.list_row, null);

    if (imageLoader == null) imageLoader = AppController.getInstance().getImageLoader();
    NetworkImageView thumbNail = (NetworkImageView) convertView.findViewById(R.id.thumbnail);
    TextView username = (TextView) convertView.findViewById(R.id.username);
    TextView phone = (TextView) convertView.findViewById(R.id.phone);

    // getting user data for the row
    User user = userItems.get(position);

    // thumbnail image
    thumbNail.setImageUrl(user.getThumbnailUrl(), imageLoader);

    // username
    username.setText(user.getUsername());

    // phone
    phone.setText(user.getPhone());

    return convertView;
  }
 public MapzenNotificationCreator(Activity act) {
   baseActivity = act;
   mNotificationManager =
       (NotificationManager)
           baseActivity.getSystemService(
               baseActivity.getApplicationContext().NOTIFICATION_SERVICE);
 }