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;
  }
示例#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();
   }
 }
示例#3
0
  /**
   * 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 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();
  }
示例#6
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();
 }
    @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;
    }
示例#8
0
 @Override
 public void onFinishExitDialog(boolean exit) {
   if (exit == true) {
     Toast.makeText(this, TAG + "onFinishExitDialog()", Toast.LENGTH_SHORT);
     finish();
   }
 }
示例#9
0
 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;
 }
示例#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);
    }
  }
示例#11
0
  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();
  }
示例#12
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));
 }
示例#13
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();
      }
    }
示例#15
0
  @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();
    }
  }
示例#17
0
  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();
  }
  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));
  }
 public void eventTextClicked(int event_id) {
   // Do something when the event is clicked
   Toast.makeText(getApplicationContext(), "Event clicked: " + event_id, Toast.LENGTH_SHORT)
       .show();
 }
  public void tryLogin() {
    mName = mEtAccount.getText().toString();
    mPassword = mEtPassword.getText().toString();

    if (mName.equals("") || mPassword.length() < 5) { // Please Specify Your Name and Sex"
      Toast.makeText(
              MainActivity.this,
              "Please Specify Your Name and Password correctly",
              Toast.LENGTH_LONG)
          .show();
    } else {
      mUserInfo = new UserInfo(mName, 0, 0, 0, 0, 0, 0);

      /*  if mNetcon is connected already, close it first  */
      /*  here we use try because mNetCon might not have been instantiated yet  */
      /*			try {
      				NetConnect.getnetConnect().closeNetConnect();
      			} catch (Exception e) {}
      			try {
      				InitData.closeInitData();
      				FriendListInfo.closeFriendListInfo();
      				ChatServiceData.closeChatServiceData();
      			} catch (Exception e) {}
      */
      CloseAll.closeAll();
      /*  to establish a new connect  */

      NetworkService.getInstance().onInit(this);
      NetworkService.getInstance().setupConnection();
      if (NetworkService.getInstance().getIsConnected()) {
        String usrInfo =
            mUserInfo.toString()
                + GlobalStrings.signinDivider
                + mPassword
                + GlobalStrings.signinDivider;
        NetworkService.getInstance().sendUpload(GlobalMsgTypes.msgHandShake, usrInfo);
      } else {
        NetworkService.getInstance().closeConnection();
        Toast.makeText(this, "failed to connect to Server", Toast.LENGTH_LONG).show();
        return;
      }

      InitData initData = InitData.getInitData();
      initData.start();
      try {
        initData.join();
      } catch (Exception e) {
      }
      mUserInfo = initData.getUserInfo();

      Log.d(
          "connectedApp isonline : ",
          ""
              + mUserInfo.getIsOnline()
              + "+++++++++++++"
              + "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");

      if (mUserInfo.getId() < 0) {
        Toast.makeText(this, "invalid username or password", Toast.LENGTH_SHORT).show();
        return;
      }

      Log.d(
          "connectedApp isonline : ",
          ""
              + mUserInfo.getIsOnline()
              + "+++++++++++++"
              + "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");

      ConnectedApp connected_app0 = ConnectedApp.getInstance();
      //		    connected_app0.setConnect(mNetCon);
      connected_app0.setUserInfo(mUserInfo);
      connected_app0.clearListActivity();
      connected_app0.instantiateListActivity();

      Intent intent0 = new Intent(MainActivity.this, MainBodyActivity.class);
      //			intent0.putExtra("username", mUserInfo.getName());
      //			intent0.putExtra("usersex", mUserInfo.getSex());
      startActivity(intent0);

      finish();
    }
  }