public boolean onContextItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case 1:
        mBtn.setTextColor(Color.RED);
        return true;
      case 2:
        mBtn.setTextColor(Color.GREEN);
        return true;
      case 3:
        mBtn.setTextColor(Color.BLUE);
        return true;
      case 4:
        Toast.makeText(this, "번역했다.", Toast.LENGTH_SHORT).show();
        return true;
      case 5:
        Toast.makeText(this, "필기 인식했다.", Toast.LENGTH_SHORT).show();
        return true;
      case 100:
        Toast.makeText(this, "회전했다 치고.", Toast.LENGTH_SHORT).show();
        return true;
      case 101:
        Toast.makeText(this, "크기 변경 했다 치고.", Toast.LENGTH_SHORT).show();
        return true;
    }

    return true;
  }
Exemple #2
0
 @Override
 public void onConfigurationChanged(Configuration newConfig) {
   super.onConfigurationChanged(newConfig);
   // Checks the orientation of the screen
   if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
     Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
   } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
     Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();
   }
 }
  /**
   * Checks if there is a call in progress. If true then shows a warning toast and finishes the
   * activity.
   *
   * @param activity activity doing a check.
   * @return <tt>true</tt> if there is call in progress and <tt>Activity</tt> was finished.
   */
  public static boolean checkCallInProgress(Activity activity) {
    if (CallManager.getActiveCallsCount() > 0) {
      logger.warn("Call is in progress");

      Toast t =
          Toast.makeText(activity, R.string.service_gui_WARN_CALL_IN_PROGRESS, Toast.LENGTH_SHORT);
      t.show();

      activity.finish();
      return true;
    } else {
      return false;
    }
  }
    @Override
    protected void onPostExecute(Boolean result) {
      if (dialogShow) progDialog.cancel();
      if (result) {
        Toast.makeText(RssReaderActivity.this, R.string.rss_items_update_done, Toast.LENGTH_SHORT)
            .show();
        rssFeed = dbQuery.getRssFeed(name, limit);
        updateListView();
      } else
        Toast.makeText(RssReaderActivity.this, R.string.rss_item_not_update, Toast.LENGTH_SHORT)
            .show();

      dbQuery.updateRssItems();
      isTaskRunning = false;
    }
    @Override
    protected void onPreExecute() {
      if (dialogShow) {
        progDialog = new ProgressDialog(RssReaderActivity.this);
        progDialog.setCancelable(false);
        progDialog.setMessage(getString(R.string.rss_fetching));
        progDialog.setButton(
            DialogInterface.BUTTON_NEGATIVE,
            getString(R.string.btn_hide_text),
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                Toast.makeText(
                        RssReaderActivity.this, R.string.rss_keep_updating, Toast.LENGTH_SHORT)
                    .show();
              }
            });
        progDialog.show();
      } else
        Toast.makeText(RssReaderActivity.this, R.string.rss_start_updating, Toast.LENGTH_SHORT)
            .show();

      isTaskRunning = true;
    }
  @Override
  protected void onStart() {
    final GameBoard boardView = (GameBoard) this.findViewById(R.id.gameBoard);
    SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE);

    this.level = prefs.getInt("level", 0);
    String mapJson = prefs.getString("map", null);

    if (mapJson == null) {
      waitForNext = true;
    } else {
      this.game.initGame(mapJson);
      String howdyPosition = prefs.getString("howdy", null);

      if (howdyPosition != null) {
        this.game.setHowdyPosition(howdyPosition);
      }

      Toast.makeText(this, this.level + "", Toast.LENGTH_SHORT).show();
    }

    String allDoneLevelsString = prefs.getString("doneLevels", null);

    if (allDoneLevelsString != null) {
      allDoneLevels = new ArrayList<String>(Arrays.asList(allDoneLevelsString.split(",")));
    }

    super.onStart();
  }
Exemple #7
0
 @Override
 public void onFinishExitDialog(boolean exit) {
   if (exit == true) {
     Toast.makeText(this, TAG + "onFinishExitDialog()", Toast.LENGTH_SHORT);
     finish();
   }
 }
Exemple #8
0
 void copyIntent() {
   ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
   Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
   ClipData clip = ClipData.newIntent("intent", intent);
   cm.setPrimaryClip(clip);
   Toast.makeText(this, "Intent Copied", 0).show();
 }
 public boolean onTouchEvent(MotionEvent event) {
   super.onTouchEvent(event);
   if (event.getAction() == MotionEvent.ACTION_DOWN) {
     Toast.makeText(HandleEvent.this, "Touch Event Received", Toast.LENGTH_SHORT).show();
     return true;
   }
   return false;
 }
Exemple #10
0
  void pasteIntent() {
    ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    if (cm.hasPrimaryClip() == false) {
      Toast.makeText(this, "Clipboard Empty", 0).show();
      return;
    }
    if (cm.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_INTENT) == false) {
      Toast.makeText(this, "Clip is not intent", 0).show();
      return;
    }

    ClipData clip = cm.getPrimaryClip();
    ClipData.Item item = clip.getItemAt(0);
    Intent intent = item.getIntent();
    if (intent != null) {
      startActivity(intent);
    }
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == Activity.RESULT_OK) {
      String sdStatus = Environment.getExternalStorageState();
      if (!sdStatus.equals(Environment.MEDIA_MOUNTED)) { // 检测sd是否可用
        Log.i("TestFile", "SD card is not avaiable/writeable right now.");
        return;
      }
      String name =
          new DateFormat().format("yyyyMMdd_hhmmss", Calendar.getInstance(Locale.CHINA)) + ".jpg";
      Toast.makeText(this, name, Toast.LENGTH_LONG).show();
      Bundle bundle = data.getExtras();
      Bitmap bitmap = (Bitmap) bundle.get("data"); // 获取相机返回的数据,并转换为Bitmap图片格式

      FileOutputStream b = null;
      File file = new File("/sdcard/myImage/");
      if (!file.exists()) file.mkdirs(); // 创建文件夹

      String fileName = "/sdcard/myImage/" + name;
      File photofile = new File(fileName);
      if (!photofile.exists()) {
        try {
          photofile.createNewFile();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      try {
        b = new FileOutputStream(photofile);
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, b); // 把数据写入文件
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        try {
          b.flush();
          b.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      // 动态的改变gridview中的一个Item的内容
      bitmapList.set(currentIndex, bitmap);
      myGalleryAdapter.notifyDataSetChanged();
      updatePhoto(
          Long.valueOf(phoneNumberToId.get(phoneNumber.get(currentIndex))), bitmapToBytes(bitmap));
      //            ((ImageView) findViewById(R.id.imageView)).setImageBitmap(bitmap);//
      // 将图片显示在ImageView里
      Intent intent = new Intent(ContactActivity.this, ContactActivity.class);
      this.startActivity(intent);
      this.finish();
    }
  }
  private void loadData(String providerName, boolean limit, boolean dialogShow, boolean update) {
    int maxItemLoad = limit ? dbQuery.getRssSettings()[1] : 0;
    rssFeed = dbQuery.getRssFeed(providerName, maxItemLoad);

    if (providerName == null) curProvider = -1;
    updateListView();

    if (isTaskRunning)
      Toast.makeText(RssReaderActivity.this, R.string.rss_keep_updating, Toast.LENGTH_SHORT).show();
    else if (update) new RssDownloadTask(providerName, maxItemLoad, dialogShow).execute();
  }
Exemple #13
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.set_menu_save:
       save();
       return true;
     case R.id.set_menu_return:
       Toast.makeText(getApplicationContext(), "操作无效。", Toast.LENGTH_SHORT).show();
       return true;
   }
   return (super.onOptionsItemSelected(item));
 }
  private void sendMessage(String msg) {
    Log.d(TAG, "Sending Result=" + msg);

    if (characteristicReady
        && (mBluetoothLeService != null)
        && (characteristicTX != null)
        && (characteristicRX != null)) {
      characteristicTX.setValue(msg);
      mBluetoothLeService.writeCharacteristic(characteristicTX);
      mBluetoothLeService.setCharacteristicNotification(characteristicRX, true);
    } else {
      Toast.makeText(DeviceControlActivity.this, "BLE Disconnected", Toast.LENGTH_SHORT).show();
    }
  }
Exemple #15
0
 public void save() {
   if (rs.isChecked() == true) {
     edit.putBoolean("silent", true);
     edit.commit();
   } else {
     edit.putBoolean("silent", false);
     edit.commit();
   }
   if (nc.isChecked() == true) {
     edit.putBoolean("nightmode", true);
     edit.commit();
   } else {
     edit.putBoolean("nightmode", false);
     edit.commit();
   }
   Toast.makeText(getApplicationContext(), "保存成功!", Toast.LENGTH_SHORT).show();
 }
    protected void onPostExecute(String[] result) {
      // ("Download complete: " + result + "\nComplete");

      if (result.length < 2) {
        text1.setText("Error: " + result[0]);

      } else {
        // text1.setText("Starting download " + result[1] + "... " + result[0]);

        doDownload(result[0], result[1]);

        finish();

        Toast.makeText(mContext.get(), "Downloading " + result[1] + "...", Toast.LENGTH_LONG)
            .show();
      }
    }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);

    switch (item.getItemId()) {
      case R.id.mnu_exit:
        if (!isTaskRunning) finish();
        else
          Toast.makeText(RssReaderActivity.this, R.string.rss_keep_updating, Toast.LENGTH_SHORT)
              .show();
        break;
      case R.id.mnu_about:
        break;
      default:
        break;
    }
    return true;
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.receiver);

    final Button cancelbtn = (Button) findViewById(R.id.ButtonCancel);
    // cancelbtn.setEnabled(false);
    cancelbtn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // streamtask.cancel(true);
            finish();
          }
        });

    try {
      Intent intent = getIntent();
      String action = intent.getAction();
      String type = intent.getType();

      if ((!(Intent.ACTION_SEND.equals(action))) || (type == null)) {
        throw new RuntimeException("Unknown intent action or type");
      }

      if (!("text/plain".equals(type))) {
        throw new RuntimeException("Type is not text/plain");
      }

      String extra = intent.getStringExtra(Intent.EXTRA_TEXT);
      if (extra == null) {
        throw new RuntimeException("Cannot get shared text");
      }

      final DownloadStreamTask streamtask = new DownloadStreamTask(this);

      //	Once created, a task is executed very simply:
      streamtask.execute(extra);

    } catch (Exception e) {
      Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
    }
  }
Exemple #19
0
  public void mOnClickSave(View v) {
    String inputPath = nowPath;
    UseDb db = new UseDb();

    File files = new File(inputPath);
    if (files.exists() == true) {
      db.setValue(this, dbPath, nowPath);

      Intent intent = new Intent(this, Loading.class);
      intent.putExtra("path", nowPath);
      startActivity(intent);

      finish();
    } else {
      Toast.makeText(
              FolderEx.this,
              getResources().getString(R.string.sp_msg_notexistfolder),
              Toast.LENGTH_SHORT)
          .show();
    }
  }
 private void gotoBookmark(Bookmark bookmark) {
   bookmark.onOpen();
   final FBReader fbreader = (FBReader) FBReader.Instance();
   final long bookId = bookmark.getBookId();
   if ((fbreader.Model == null) || (fbreader.Model.Book.getId() != bookId)) {
     final Book book = Book.getById(bookId);
     if (book != null) {
       finish();
       fbreader.openBook(book, bookmark);
     } else {
       Toast.makeText(
               this,
               ZLResource.resource("errorMessage").getResource("cannotOpenBook").getValue(),
               Toast.LENGTH_SHORT)
           .show();
     }
   } else {
     finish();
     fbreader.gotoBookmark(bookmark);
   }
 }
 /**
  * onClick
  *
  * <p>extracts the relai that was clicked, and asks the ipx to open then close the corresponding
  * relai
  */
 @Override
 public void onClick(View view) {
   Ipx800Control ipx = context.getIpx();
   if (view instanceof Button) {
     Button button = (Button) view;
     // Log.d(TAG, "hit the button " + button.getHint()+ "id = "+button.getId());
     try {
       int port2trigger = Integer.parseInt("" + button.getHint());
       // Log.d(TAG, "would trigger ipx out "+port2trigger);
       try {
         ipx.set(port2trigger, true);
         ipx.set(port2trigger, false);
       } catch (Exception e) {
         Toast.makeText(context, "error:" + e, Toast.LENGTH_LONG).show();
       }
     } catch (NumberFormatException e) {
       // ok, we hit a special button....
       if (button.getId() == R.id.servernameValue) context.callSettings();
       else if (button.getHint().equals("fill_me")) context.callSettings();
       // else Log.e(TAG,"unknown button code: "+button.getHint());
     }
   }
 }
  private void selectItem(int index) {
    _info = mInfoList.get(index);
    if (!(new File(_info.archiveFile)).exists()) {
      String text =
          String.format(
              Locale.ENGLISH,
              "Location '%s' cannot be selected!\n" + "Please, download location first!",
              _info.title);
      Toast.makeText(mContext, text, Toast.LENGTH_LONG).show();
      return;
    }

    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(mContext);
    alertBuilder.setTitle(String.format(Locale.ENGLISH, "Location '%s'", _info.title));

    alertBuilder.setNegativeButton(
        "Delete location",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {
            deleteLocation(_info);
          }
        });
    alertBuilder.setPositiveButton(
        "Select location",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {
            selectLocation(_info);
          }
        });

    AlertDialog dialog = alertBuilder.create();
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
  }
Exemple #23
0
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {

    File file;
    String fileName = item.get(position);

    file = new File(itemPath.get(position));

    if (file.isDirectory()) {
      if (file.canRead()) {
        selectFile = file.toString();
        getDir(itemPath.get(position), "");
      } else {
        Toast toast = Toast.makeText(this, "Cannot read directory", 2000);
        toast.show();
      }
    } else {
      if (openCode == mXMLImp) {
        try {
          String value = file.getName();

          if (value != null && value.length() > 0) {
            i = new Intent(this, getText.class);
            String shortName;
            int len = value.length();
            shortName = value.substring(4, len - 8);
            i.putExtra("value", shortName);
            startActivityForResult(i, mXMLImp);

            //                    String fileOut = nameDialog("Import to:", value);
            //                    CreateShopDatabase.DATABASE_NAME = fileOut;
            //                    CreateShopDatabase.DATABASE_NAME = "new.abb";
            // do something with value
            /* Do not import until filename is found
                                mDbHelper = new ShopDbAdapter(this);

                                Intent i = new Intent(this, xmlActivity.class);
                                i.putExtra("file", value);

                                startActivity(i);
            */

          }
        } catch (Exception ignored) {
        }
      }

      Toast toast = Toast.makeText(this, "[" + file.getName() + "]", 2000);
      toast.show();

      //			ShopDbAdapter.close();

      selectFile = file.getName();
      xmlFileIn = file.getPath();

      if (openCode != mXMLImp) {
        CreateShopDatabase.DATABASE_NAME = file.getName();
        setResult(0);
        finish();
      }
    }
  }
  public void nextLevel() {
    boolean loaded = false;
    final GameBoard boardView = (GameBoard) this.findViewById(R.id.gameBoard);
    this.level++;

    AssetManager am = getResources().getAssets();

    try {
      List<String> allTutoLevels =
          new LinkedList<String>(Arrays.asList(am.list("levels/tutorial")));

      // if(addMsg){
      //    allTutoLevels.addAll(Arrays.asList(am.list("msg")));
      // }

      Log.d(TAG, allTutoLevels.toString());

      for (String name : allTutoLevels) {
        if (name.startsWith(this.level + ".")) {
          BufferedReader br =
              new BufferedReader(new InputStreamReader(am.open("levels/tutorial/" + name)));
          String line;
          String levelJSON = "";

          while ((line = br.readLine()) != null) {
            levelJSON += line + "\n";
          }

          br.close();

          game.initGame(
              levelJSON, boardView.getMeasuredWidth() / 60, boardView.getMeasuredHeight() / 60);
          loaded = true;
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
    }

    if (!loaded) {
      Random r = new Random();

      List<String> allLevels = new ArrayList<>();

      try {
        allLevels = Arrays.asList(am.list("levels"));
      } catch (IOException e) {
      }

      if (r.nextBoolean() && !allLevels.isEmpty() && allLevels.size() != allDoneLevels.size()) {
        try {
          int nLevel;
          do {
            nLevel = r.nextInt(allLevels.size());
          } while (allDoneLevels.contains(allLevels.get(nLevel)));

          String name = allLevels.get(nLevel);
          BufferedReader br = new BufferedReader(new InputStreamReader(am.open("levels/" + name)));

          String line;
          String levelJSON = "";

          while ((line = br.readLine()) != null) {
            levelJSON += line + "\n";
          }

          br.close();

          allDoneLevels.add(name);

          game.initGame(
              levelJSON, boardView.getMeasuredWidth() / 60, boardView.getMeasuredHeight() / 60);
        } catch (IOException e) {
          this.game.initGame(
              level, boardView.getMeasuredWidth() / 60, boardView.getMeasuredHeight() / 60);
        }
      } else {
        this.game.initGame(
            level, boardView.getMeasuredWidth() / 60, boardView.getMeasuredHeight() / 60);
      }
    }

    // am.close();

    boardView.setGame(this.game);
    boardView.invalidate();
    boardView.getHowdyShadeView().invalidate();

    Toast.makeText(this, this.level + "", Toast.LENGTH_SHORT).show();

    Log.i(
        TAG,
        "Max tiles : "
            + (boardView.getMeasuredWidth() / 60) * (boardView.getMeasuredHeight() / 60));
  }