@Override
        public void onReceive(Context context, Intent intent) {
          final String action = intent.getAction();
          if (BluetoothLeService.ACTION_GATT_CONNECTED.equals(action)) {
            mConnected = true;
            updateConnectionState(R.string.connected);
            invalidateOptionsMenu();
          } else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) {
            mConnected = false;
            updateConnectionState(R.string.disconnected);
            invalidateOptionsMenu();
          } else if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) {
            BluetoothGattService gattService = mBluetoothLeService.getSoftSerialService();
            characteristicTX = gattService.getCharacteristic(BluetoothLeService.UUID_HM_RX_TX);
            // characteristicRX = gattService.getCharacteristic(BluetoothLeService.UUID_HM_RX_TX);
            characteristicRX = characteristicTX;

            if ((gattService != null) && (characteristicTX != null)) {
              mBluetoothLeService.setCharacteristicNotification(characteristicTX, true);

              isSerial.setText("Serial ready");
              updateReadyState(R.string.ready);
            } else {
              isSerial.setText("Serial can't be found");
            }

          } else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) {
            displayData(intent.getStringExtra(mBluetoothLeService.EXTRA_DATA));
          }
        }
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mListView = (ListView) mView.findViewById(R.id.lv);
    mListView.setOnScrollListener(
        new AbsListView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(AbsListView view, int scrollState) {
            if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
              PullRightLayout.collapseAll();
            }
          }

          @Override
          public void onScroll(
              AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {}
        });

    mStartScanView = (TextView) mView.findViewById(R.id.tv_start_scan);
    mStartScanView.setBackgroundColor(ThemeManager.with(getActivity()).getCurrentColor());
    mStartScanView.setOnClickListener(this);

    mPullLayout = (PullLayout) mView.findViewById(R.id.pull_layout);
    mPullLayout.addOnPullListener(this);
    if (mListener != null) {
      mPullLayout.addOnPullListener(mListener);
      mListener = null;
    }

    mIvScan = (ImageView) mView.findViewById(R.id.iv_scan);

    IntentFilter filter = new IntentFilter(ScanService.ACTION_SCAN_FINISH);
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(receiver, filter);
  }
 private void initPagerItems() {
   for (int i = 0; i < bitmapList.size(); i++) {
     View v = LayoutInflater.from(this).inflate(R.layout.call_activity_itempage, null);
     ImageView imageView = (ImageView) v.findViewById(R.id.contactIv);
     TextView textView = (TextView) v.findViewById(R.id.contactTv);
     imageView.setImageBitmap(bitmapList.get(i));
     textView.setText(nameList.get(i));
     viewArrayList.add(v);
   }
 }
  public void onResume() {
    super.onResume();

    // Log.i("WaveLoop", "onStart");

    if (PlayerProxy.instance() == null) {
      // mNowPlayingMain.setEnabled(false);
      // mNowPlayingMain.setVisibility(View.INVISIBLE);

      mWaveLoopMain.removeView(mNowPlayingMain);
      return;
    }

    final AudioInfo audioInfo = PlayerProxy.getAudioInfo();
    if (audioInfo != null) {
      mWaveLoopMain.removeView(mNowPlayingMain);
      mWaveLoopMain.addView(mNowPlayingMain);

      // mNowPlayingMain.setEnabled(true);
      // mNowPlayingMain.setVisibility(View.VISIBLE);

      mNowPlayingArtist.setText(audioInfo.artist);
      mNowPlayingAlbum.setText(audioInfo.album);
      mNowPlayingTitle.setText(audioInfo.title);

      mNowPlayingPlayBtn.setImageResource(
          (PlayerProxy.isPlaying()) ? R.drawable.pause_bkgnd : R.drawable.play_bkgnd);

      mNowPlayingPlayBtn.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (PlayerProxy.isPlaying()) PlayerProxy.pause();
              else PlayerProxy.play();

              mNowPlayingPlayBtn.setImageResource(
                  (PlayerProxy.isPlaying()) ? R.drawable.pause_bkgnd : R.drawable.play_bkgnd);
            }
          });

      mNowPlayingBtn.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              Intent i = new Intent(WaveLoopActivity.this, player_main.class);
              i.putExtra("오디오파일경로", (int) audioInfo.dataRowId);
              startActivity(i);
            }
          });
    } else {
      mWaveLoopMain.removeView(mNowPlayingMain);
      // mNowPlayingMain.setEnabled(false);
      // mNowPlayingMain.setVisibility(View.INVISIBLE);
    }
  }
  private View getEmptyView() {
    if (mEmptyRoot == null) {
      mEmptyRoot = mView.findViewById(R.id.empty_root);
      ImageView mIvEmpty = (ImageView) mView.findViewById(R.id.iv_empty);
      TextView mTvEmpty = (TextView) mView.findViewById(R.id.tv_empty);

      mIvEmpty.setImageResource(R.drawable.hand);
      mTvEmpty.setText("下拉扫描新歌曲");
    }
    return mEmptyRoot;
  }
    public View getView(int position, View convertView, ViewGroup parent) {
      final View view =
          (convertView != null)
              ? convertView
              : LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.bookmark_item, parent, false);
      final ImageView imageView = (ImageView) view.findViewById(R.id.bookmark_item_icon);
      final TextView textView = (TextView) view.findViewById(R.id.bookmark_item_text);
      final TextView bookTitleView = (TextView) view.findViewById(R.id.bookmark_item_booktitle);

      final Bookmark bookmark = getItem(position);
      if (bookmark == null) {
        imageView.setVisibility(View.VISIBLE);
        imageView.setImageResource(R.drawable.ic_list_plus);
        textView.setText(ZLResource.resource("bookmarksView").getResource("new").getValue());
        bookTitleView.setVisibility(View.GONE);
      } else {
        imageView.setVisibility(View.GONE);
        textView.setText(bookmark.getText());
        if (myCurrentBook) {
          bookTitleView.setVisibility(View.GONE);
        } else {
          bookTitleView.setVisibility(View.VISIBLE);
          bookTitleView.setText(bookmark.getBookTitle());
        }
      }
      return view;
    }
  public void onFileName(String newFileName) {
    if (newFileName == null || newFileName.length() <= 0) {
      return;
    }

    TextView txtFilename = (TextView) findViewById(R.id.txtFileName);

    if (AppSettings.shouldLogToGpx() || AppSettings.shouldLogToKml()) {

      txtFilename.setText(
          getString(R.string.summary_current_filename_format, Session.getCurrentFileName()));
    } else {
      txtFilename.setText("");
    }
  }
  /** Called when the activity is first created */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "LoaderActivity created");
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.content);

    // Instantiate custom adapter
    mAdapter = new LoaderAdapter();

    // Handle listview and assign adapter
    mListView = (ListView) findViewById(R.id.content_list_view);
    mListView.setAdapter(mAdapter);
    mListView.setVisibility(View.GONE);
    mListView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          public boolean onItemLongClick(AdapterView parent, View view, int position, long id) {
            selectItem(position);
            return true;
          }
        });

    mStatusLabel = (TextView) findViewById(R.id.content_status_label);
    mStatusLabel.setVisibility(View.VISIBLE);

    String userHash = NavigineApp.Settings.getString("user_hash", "");
    if (userHash.length() == 0) showUserHashDialog();
    else refreshMapList();
  }
  /* Scan the files in the new directory, and store them in the filelist.
   * Update the UI by refreshing the list adapter.
   */
  private void loadDirectory(String newdirectory) {
    if (newdirectory.equals("../")) {
      try {
        directory = new File(directory).getParent();
      } catch (Exception e) {
      }
    } else {
      directory = newdirectory;
    }
    SharedPreferences.Editor editor = getPreferences(0).edit();
    editor.putString("lastBrowsedDirectory", directory);
    editor.commit();
    directoryView.setText(directory);

    filelist = new ArrayList<FileUri>();
    ArrayList<FileUri> sortedDirs = new ArrayList<FileUri>();
    ArrayList<FileUri> sortedFiles = new ArrayList<FileUri>();
    if (!newdirectory.equals(rootdir)) {
      String parentDirectory = new File(directory).getParent() + "/";
      Uri uri = Uri.parse("file://" + parentDirectory);
      sortedDirs.add(new FileUri(uri, parentDirectory));
    }
    try {
      File dir = new File(directory);
      File[] files = dir.listFiles();
      if (files != null) {
        for (File file : files) {
          if (file == null) {
            continue;
          }
          String filename = file.getName();
          if (file.isDirectory()) {
            Uri uri = Uri.parse("file://" + file.getAbsolutePath() + "/");
            FileUri fileuri = new FileUri(uri, uri.getPath());
            sortedDirs.add(fileuri);
          } else if (filename.endsWith(".mid")
              || filename.endsWith(".MID")
              || filename.endsWith(".midi")
              || filename.endsWith(".MIDI")) {

            Uri uri = Uri.parse("file://" + file.getAbsolutePath());
            FileUri fileuri = new FileUri(uri, uri.getLastPathSegment());
            sortedFiles.add(fileuri);
          }
        }
      }
    } catch (Exception e) {
    }

    if (sortedDirs.size() > 0) {
      Collections.sort(sortedDirs, sortedDirs.get(0));
    }
    if (sortedFiles.size() > 0) {
      Collections.sort(sortedFiles, sortedFiles.get(0));
    }
    filelist.addAll(sortedDirs);
    filelist.addAll(sortedFiles);
    adapter = new IconArrayAdapter<FileUri>(this, android.R.layout.simple_list_item_1, filelist);
    this.setListAdapter(adapter);
  }
 @Override
 public void onThemeChange(int color) {
   mStartScanView.setBackgroundColor(color);
   if (mSongAdapter != null) {
     mSongAdapter.notifyDataSetChanged();
   }
 }
  public void onTimeSet(TimePicker view, int h, int m) {

    selected_datetime.set(Calendar.HOUR_OF_DAY, h);
    selected_datetime.set(Calendar.MINUTE, m);
    selected_textview.setText(date_format.format(selected_datetime.getTime()));
    // updateValues();
    // testClickButton();
  }
Exemple #12
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    c = this;
    preferences = PreferenceManager.getDefaultSharedPreferences(c);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.gpu_sgx540);

    gpuCurrent = readFile(Constants.GPU_SGX540);
    seekGpu = (SeekBar) findViewById(R.id.seek_gpu);

    gpu = Arrays.asList(153, 307, 384);
    seekBar(gpu.size() - 1, gpu.indexOf(gpuCurrent));

    /*else{
    seekGpu.setEnabled(false);
    seekIva.setEnabled(false);
    TextView ns = (TextView)findViewById(R.id.not_supported);
    ns.setVisibility(View.VISIBLE);
    }*/
    preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

    curGpuTxt = (TextView) findViewById(R.id.current_gpu);
    maxGpuTxt = (TextView) findViewById(R.id.max_gpu);
    minGpuTxt = (TextView) findViewById(R.id.min_gpu);

    mhz = getResources().getString(R.string.mhz);
    current = getResources().getString(R.string.current);
    max = getResources().getString(R.string._max);
    min = getResources().getString(R.string._min);
    curGpuTxt.setText(current + ": " + (gpuCurrent) + mhz);
    maxGpuTxt.setText(max + ": " + gpu.get(2) + mhz);
    minGpuTxt.setText(min + ": " + gpu.get(0) + mhz);

    Button cancel = (Button) findViewById(R.id.cancel);
    cancel.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            finish();
          }
        });
  }
 public void restartGame(View v) {
   for (int i = 1; i <= 9; i++) {
     View mainView =
         findViewById(
             getResources()
                 .getIdentifier("mainView" + Integer.toString(i), "id", getPackageName()));
     if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
       mainView.setBackgroundDrawable(getResources().getDrawable(R.drawable.empty));
     } else {
       mainView.setBackground(getResources().getDrawable(R.drawable.empty));
     }
     player = 1;
     matriz = new int[3][3];
     tv.setText("Jogador 1");
     tv1.setText("");
     vencedor = false;
   }
 }
Exemple #14
0
 @Override
 public boolean onTouch(View view, MotionEvent event) {
   String str = null;
   int i = 0;
   str =
       "x="
           + event.getX(i) / view.getMeasuredWidth()
           + ",y="
           + event.getY(i) / view.getMeasuredHeight();
   textView.setText(str);
   return false;
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    sdk = android.os.Build.VERSION.SDK_INT;
    player = 1;

    tv = (TextView) findViewById(R.id.mainTextView);
    tv1 = (TextView) findViewById(R.id.mainTextViewVencedor);
    tv.setText("Jogador 1");
  }
 @Override
 public void bindView(View view, Context context, Cursor cursor) {
   super.bindView(view, context, cursor);
   TextView setup = (TextView) view.findViewById(R.id.text3);
   TextView reply = (TextView) view.findViewById(R.id.text4);
   locationCursor.moveToPosition(cursor.getPosition());
   long rt = locationCursor.getLong(1);
   if (rt > 0) {
     Calendar cal = Calendar.getInstance();
     cal.setTimeInMillis(rt);
     DateFormat sdf = SimpleDateFormat.getDateTimeInstance();
     setup.setText("requested on: " + sdf.format(cal.getTime()));
   } else {
     setup.setText("requested on: <not available>");
   }
   rt = locationCursor.getLong(2);
   if (rt > 0) {
     Calendar cal = Calendar.getInstance();
     cal.setTimeInMillis(rt);
     DateFormat sdf = SimpleDateFormat.getDateTimeInstance();
     reply.setText("updated on:" + sdf.format(cal.getTime()));
     ((ImageView) view.findViewById(R.id.status))
         .setImageResource(android.R.drawable.presence_online);
   } else {
     reply.setText("updated on: <not available>");
   }
 }
  private void updateLoader() {
    if (NavigineApp.Navigation == null) return;

    // Log.d(TAG, String.format(Locale.ENGLISH, "Update loader: %d", mLoader));

    long timeNow = DateTimeUtils.currentTimeMillis();
    if (mLoader < 0) return;

    int status = LocationLoader.checkLocationLoader(mLoader);
    if (status < 100) {
      if ((Math.abs(timeNow - mLoaderTime) > LOADER_TIMEOUT / 3 && status == 0)
          || (Math.abs(timeNow - mLoaderTime) > LOADER_TIMEOUT)) {
        mListView.setVisibility(View.GONE);
        mStatusLabel.setVisibility(View.VISIBLE);
        mStatusLabel.setText("Loading timeout!\nPlease, check your internet connection!");
        Log.d(TAG, String.format(Locale.ENGLISH, "Load stopped on timeout!"));
        LocationLoader.stopLocationLoader(mLoader);
        mLoader = -1;
      } else {
        mListView.setVisibility(View.GONE);
        mStatusLabel.setVisibility(View.VISIBLE);
        mStatusLabel.setText(String.format(Locale.ENGLISH, "Loading content (%d%%)", status));
      }
    } else {
      Log.d(TAG, String.format(Locale.ENGLISH, "Load finished with result: %d", status));
      LocationLoader.stopLocationLoader(mLoader);
      mLoader = -1;

      if (status == 100) {
        parseMapsXml();
        if (mInfoList.isEmpty()) {
          mListView.setVisibility(View.GONE);
          mStatusLabel.setVisibility(View.VISIBLE);
          mStatusLabel.setText("No locations available");
        } else {
          mListView.setVisibility(View.VISIBLE);
          mStatusLabel.setVisibility(View.GONE);
        }
      } else {
        mListView.setVisibility(View.GONE);
        mStatusLabel.setVisibility(View.VISIBLE);
        mStatusLabel.setText("Error loading!\nPlease, check your ID!");
      }
    }
  }
Exemple #18
0
 public void handleMessage(Message msg) {
   mValue++;
   mText.setText(Integer.toString(mValue));
   try {
     Thread.sleep(50);
   } catch (InterruptedException e) {;
   }
   if (mValue < 100 && mQuit == false) {
     mProgress.setProgress(mValue);
     mHandler.sendEmptyMessage(0);
   } else {
     dismissDialog(0);
   }
 }
Exemple #19
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.menus);

    String name = "Test";
    String hname = "TestH";
    String iday = "39";

    String simpleinfo = name + "���덈뀞�섏꽭��n" + hname + " 蹂묒썝�낅땲��\n" + iday + "�쇱㎏ �낆썝以묒씠��땲��";

    // TextView���쒖떆�댁쨪 �댁슜
    TextView tv = (TextView) findViewById(R.id.simpleinfo);
    tv.setText(simpleinfo);

    findViewById(R.id.mystatbtn).setOnClickListener(myClickListener);
    findViewById(R.id.noticebtn).setOnClickListener(myClickListener);
    findViewById(R.id.requestbtn).setOnClickListener(myClickListener);
    findViewById(R.id.hospitalinfobtn).setOnClickListener(myClickListener);
    findViewById(R.id.qrreadbtn).setOnClickListener(myClickListener);
    findViewById(R.id.parentcallbtn).setOnClickListener(myClickListener);
    findViewById(R.id.emergencybtn).setOnClickListener(myClickListener);
  }
  private void displayData(String data) {
    if (data != null) {
      // Log.v(TAG, "BLE Return Data : " + data);

      sbuffer.append(data);
      if (data.endsWith("\n")) {
        String tmp = sbuffer.toString();
        if (tmp.startsWith("q")) {
          returnText.setText(tmp.substring(0, tmp.length() - 1));
          onSensorChanged(tmp.substring(2));
        }
        sbuffer = new StringBuilder();
      }
    }
  }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
   if (requestCode == FILECHOOSER_RESULTCODE) { // found this from StackOverflow
     if (null == mUploadMessage) return;
     Uri result = intent == null || resultCode != RESULT_OK ? null : intent.getData();
     mUploadMessage.onReceiveValue(result);
     mUploadMessage = null;
   } else {
     // -----------I wrote this code below this line----------------------------------
     jpegData = intent.getExtras().getByteArray("image");
     Bitmap img = BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length);
     Drawable d = new BitmapDrawable(img);
     profilePicture.setBackground(d);
   }
 }
    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 void onExpanded() {
    AlphaAnimation alphaAnimation = new AlphaAnimation(0.0f, 1.0f);
    alphaAnimation.setDuration(200);
    alphaAnimation.setAnimationListener(
        new Animation.AnimationListener() {
          @Override
          public void onAnimationStart(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {
            mStartScanView.setVisibility(View.VISIBLE);
            shouldStartAnim = true;
          }

          @Override
          public void onAnimationRepeat(Animation animation) {}
        });
    mStartScanView.startAnimation(alphaAnimation);
  }
  @Override
  public void onPullChange(int cur, int max) {
    if (shouldStartAnim) {
      shouldStartAnim = false;
      AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f, 0.0f);
      alphaAnimation.setDuration(200);
      alphaAnimation.setAnimationListener(
          new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
              mStartScanView.setVisibility(View.INVISIBLE);
            }

            @Override
            public void onAnimationEnd(Animation animation) {}

            @Override
            public void onAnimationRepeat(Animation animation) {}
          });
      mStartScanView.startAnimation(alphaAnimation);
    }
  }
 private View getFooterView() {
   if (mFooterView == null) {
     FrameLayout fl = new FrameLayout(getActivity());
     TextView tv = new TextView(getActivity());
     tv.setGravity(Gravity.CENTER);
     tv.setTextColor(0xFFaaaaaa);
     tv.setBackgroundColor(0xFFffffff);
     FrameLayout.LayoutParams params =
         new FrameLayout.LayoutParams(
             ViewGroup.LayoutParams.MATCH_PARENT, (int) CommonUtils.dpToPx(getActivity(), 50));
     fl.addView(tv, params);
     mFooterView = fl;
   }
   TextView tv = (TextView) mFooterView.getChildAt(0);
   tv.setText("共有" + SongManager.with(getActivity()).getSongSize() + "首歌");
   return mFooterView;
 }
  private void updateTrackersOnView() {
    Cursor cursor =
        managedQuery(
            Tracker.Details.CONTENT_URI,
            new String[] {Tracker.Details._ID, Tracker.Details.NAME, Tracker.Details.NUMBER},
            null,
            null,
            null);
    int sz = cursor.getCount();
    footerCountText.setText("(" + sz + ")");
    requestLocationView.setEnabled(sz > 0);

    Cursor setupCursor =
        managedQuery(
            Tracker.Locations.CONTENT_URI,
            new String[] {
              Tracker.Locations._FID, Tracker.Locations.REQUEST_TIME, Tracker.Locations.UPDATE_TIME
            },
            null,
            null,
            null);

    TrackerAdapter trackerAdapter =
        new TrackerAdapter(
            this,
            R.layout.location_tracker_item,
            cursor,
            new String[] {
              Tracker.Details.NAME,
              Tracker.Details.NUMBER,
              Tracker.Details.NAME,
              Tracker.Details.NUMBER
            },
            new int[] {android.R.id.text1, android.R.id.text2, R.id.text3, R.id.text4});
    trackerAdapter.setLocationCursor(setupCursor);
    getListView().setAdapter(trackerAdapter);
  }
Exemple #27
0
  @Override
  public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
    Log.d(TAG, "onEditorAction: actionId: " + actionId + ", keyEvent: " + keyEvent);

    if ((actionId == EditorInfo.IME_ACTION_DONE)
        || ((keyEvent != null) && (keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER))) {
      Log.d(TAG, "onEditorAction: IME_ACTION_DONE || KEYCODE_ENTER");
      String input = textView.getText().toString().trim();

      if (input.length() > 0) {
        String result = "";

        try {
          result += calculator.calculate(input);
        } catch (Exception e) {
          result = "no result (" + e.getMessage() + ")";
        }

        if (listAdapter.getCount() > 0) {
          listAdapter.add("");
        }

        listAdapter.add(input + " =");
        if (input.indexOf("@") > -1) {
          listAdapter.add(calculator.getEquation() + " =");
        }
        listAdapter.add(result);
        listAdapter.notifyDataSetChanged();

        inputView.endBatchEdit();
        inputView.setText("");
        hideKeyboard();
      }
    }

    return false;
  }
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   View v = convertView;
   if (v == null) {
     LayoutInflater vi =
         (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     v = vi.inflate(R.layout.row, null);
   }
   Message m = items.get(position);
   // if (m != null) {
   m.createColorFromString(m.from);
   TextView tt = (TextView) v.findViewById(R.id.username);
   TextView bt = (TextView) v.findViewById(R.id.message);
   if (isMonospaced) {
     tt.setTypeface(Typeface.MONOSPACE);
     bt.setTypeface(Typeface.MONOSPACE);
   }
   tt.setText(m.getFrom());
   tt.setTextColor(m.color);
   bt.setText(m.getMessage());
   // }
   return v;
 }
Exemple #29
0
  /**
   * getdir -
   *
   * @param dirPath
   * @param fileNamePattern
   */
  private void getDir(String dirPath, String fileNamePattern) {
    myPath.setText("Location: " + dirPath);

    item = new ArrayList<String>();
    itemPath = new ArrayList<String>();
    path = new ArrayList<String>();

    File f = new File(dirPath);
    File file = new File(dirPath);
    File[] files = f.listFiles();

    if (!dirPath.equals(root)) {

      item.add(root);
      itemPath.add(root);
      path.add(root);

      item.add("../");
      itemPath.add("../");
      String xx = f.getParent();
      if (xx != null) {
        path.add(xx);
      } else {
        path.add(f.getName());
      }
    }

    if (files == null) {

      return;
    }

    for (File oneFile : files) {
      if (oneFile.canRead()) {
        path.add(oneFile.getPath());
      }
    }

    //        Collections.sort(item);
    //        Collections.sort(itemPath);
    Collections.sort(path);

    for (String filePath : path) {
      //            file=(file.getPath());
      file = new File(filePath);
      //            file=(filePath.);
      if (file.isDirectory()) {
        item.add(file.getName() + "/");
        itemPath.add(file.getPath() + "/");
      } else {

        if (fileNamePattern.equalsIgnoreCase("/")) {

        } else {
          {
            boolean match = file.getName().matches(fileRegExp);
            if (match) {
              String fgn = file.getName();
              int abb = fgn.lastIndexOf(".abb");
              if (abb > 10000) {
                String fgn1 = fgn.substring(0, fgn.lastIndexOf(".abb"));
                fgn = fgn.substring(0, fgn.lastIndexOf(".abb"));
              }
              item.add(fgn);
              itemPath.add(file.getPath());
            }
          }
        }
      }
    }

    ArrayAdapter<String> fileList = new ArrayAdapter<String>(this, R.layout.filesrow, item);
    setListAdapter(fileList);
  }
Exemple #30
0
  /**
   * Given a location fix, processes it and displays it in the table on the form.
   *
   * @param loc Location information
   */
  private void DisplayLocationInfo(Location loc) {
    Utilities.LogDebug("GpsMainActivity.DisplayLocationInfo");
    try {

      if (loc == null) {
        return;
      }

      TextView tvLatitude = (TextView) findViewById(R.id.txtLatitude);
      TextView tvLongitude = (TextView) findViewById(R.id.txtLongitude);
      TextView tvDateTime = (TextView) findViewById(R.id.txtDateTimeAndProvider);

      TextView tvAltitude = (TextView) findViewById(R.id.txtAltitude);

      TextView txtSpeed = (TextView) findViewById(R.id.txtSpeed);

      TextView txtSatellites = (TextView) findViewById(R.id.txtSatellites);
      TextView txtDirection = (TextView) findViewById(R.id.txtDirection);
      TextView txtAccuracy = (TextView) findViewById(R.id.txtAccuracy);
      String providerName = loc.getProvider();

      if (providerName.equalsIgnoreCase("gps")) {
        providerName = getString(R.string.providername_gps);
      } else {
        providerName = getString(R.string.providername_celltower);
      }

      tvDateTime.setText(
          new Date(Session.getLatestTimeStamp()).toLocaleString()
              + getString(R.string.providername_using, providerName));
      tvLatitude.setText(String.valueOf(loc.getLatitude()));
      tvLongitude.setText(String.valueOf(loc.getLongitude()));

      if (loc.hasAltitude()) {

        double altitude = loc.getAltitude();

        if (AppSettings.shouldUseImperial()) {
          tvAltitude.setText(
              String.valueOf(Utilities.MetersToFeet(altitude)) + getString(R.string.feet));
        } else {
          tvAltitude.setText(String.valueOf(altitude) + getString(R.string.meters));
        }

      } else {
        tvAltitude.setText(R.string.not_applicable);
      }

      if (loc.hasSpeed()) {

        float speed = loc.getSpeed();
        String unit;
        if (AppSettings.shouldUseImperial()) {
          if (speed > 1.47) {
            speed = speed * 0.6818f;
            unit = getString(R.string.miles_per_hour);

          } else {
            speed = Utilities.MetersToFeet(speed);
            unit = getString(R.string.feet_per_second);
          }
        } else {
          if (speed > 0.277) {
            speed = speed * 3.6f;
            unit = getString(R.string.kilometers_per_hour);
          } else {
            unit = getString(R.string.meters_per_second);
          }
        }

        txtSpeed.setText(String.valueOf(speed) + unit);

      } else {
        txtSpeed.setText(R.string.not_applicable);
      }

      if (loc.hasBearing()) {

        float bearingDegrees = loc.getBearing();
        String direction;

        direction = Utilities.GetBearingDescription(bearingDegrees, getApplicationContext());

        txtDirection.setText(
            direction
                + "("
                + String.valueOf(Math.round(bearingDegrees))
                + getString(R.string.degree_symbol)
                + ")");
      } else {
        txtDirection.setText(R.string.not_applicable);
      }

      if (!Session.isUsingGps()) {
        txtSatellites.setText(R.string.not_applicable);
        Session.setSatelliteCount(0);
      }

      if (loc.hasAccuracy()) {

        float accuracy = loc.getAccuracy();

        if (AppSettings.shouldUseImperial()) {
          txtAccuracy.setText(
              getString(
                  R.string.accuracy_within,
                  String.valueOf(Utilities.MetersToFeet(accuracy)),
                  getString(R.string.feet)));

        } else {
          txtAccuracy.setText(
              getString(
                  R.string.accuracy_within, String.valueOf(accuracy), getString(R.string.meters)));
        }

      } else {
        txtAccuracy.setText(R.string.not_applicable);
      }

    } catch (Exception ex) {
      SetStatus(getString(R.string.error_displaying, ex.getMessage()));
    }
  }