@Override
 public boolean onContextItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case PLAY_SELECTION:
       {
         long[] list =
             MusicUtils.getSongListForAlbum(getActivity(), Long.parseLong(mCurrentAlbumId));
         MusicUtils.playAll(getActivity(), list, 0);
         break;
       }
     case ADD_TO_PLAYLIST:
       {
         Intent intent = new Intent(INTENT_ADD_TO_PLAYLIST);
         long[] list =
             MusicUtils.getSongListForAlbum(getActivity(), Long.parseLong(mCurrentAlbumId));
         intent.putExtra(INTENT_PLAYLIST_LIST, list);
         getActivity().startActivity(intent);
         break;
       }
     case SEARCH:
       {
         MusicUtils.doSearch(getActivity(), mCursor, mAlbumNameIndex);
         break;
       }
     default:
       break;
   }
   return super.onContextItemSelected(item);
 }
Exemple #2
0
 public View getChildView(int i, int j, boolean flag, View view, ViewGroup viewgroup) {
   FacebookProfile facebookprofile = (FacebookProfile) getChild(i, j);
   View view1 = view;
   ViewHolder viewholder;
   String s;
   if (view1 == null) {
     view1 = inflateChildView(facebookprofile);
     viewholder = new ViewHolder(view1, 0x7f0e0033);
     mViewHolders.add(viewholder);
     view1.setTag(viewholder);
   } else {
     viewholder = (ViewHolder) view1.getTag();
   }
   viewholder.setItemId(Long.valueOf(facebookprofile.mId));
   s = facebookprofile.mImageUrl;
   if (s != null && s.length() != 0) {
     android.graphics.Bitmap bitmap = mUserImagesCache.get(mContext, facebookprofile.mId, s);
     if (bitmap != null) viewholder.mImageView.setImageBitmap(bitmap);
     else viewholder.mImageView.setImageResource(0x7f0200f3);
   } else {
     viewholder.mImageView.setImageResource(0x7f0200f3);
   }
   ((TextView) view1.findViewById(0x7f0e0100)).setText(facebookprofile.mDisplayName);
   return view1;
 }
  @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 updatePhoto(Long rawContactId, byte[] photo) {

    ContentValues values = new ContentValues();
    values.put(ContactsContract.Contacts.Photo.PHOTO, photo);

    String selection =
        ContactsContract.RawContacts.Data.RAW_CONTACT_ID
            + "=? and "
            + ContactsContract.RawContacts.Data.MIMETYPE
            + "=?";
    String[] selectionArgs =
        new String[] {
          Long.toString(rawContactId), ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE
        };

    getContentResolver()
        .update(ContactsContract.Data.CONTENT_URI, values, selection, selectionArgs);
  }
Exemple #5
0
  @Override
  public void onDownloadProgress(DownloadProgressInfo progress) {
    mAverageSpeed.setText(
        getString(
            com.godot.game.R.string.kilobytes_per_second,
            Helpers.getSpeedString(progress.mCurrentSpeed)));
    mTimeRemaining.setText(
        getString(
            com.godot.game.R.string.time_remaining,
            Helpers.getTimeRemaining(progress.mTimeRemaining)));

    progress.mOverallTotal = progress.mOverallTotal;
    mPB.setMax((int) (progress.mOverallTotal >> 8));
    mPB.setProgress((int) (progress.mOverallProgress >> 8));
    mProgressPercent.setText(
        Long.toString(progress.mOverallProgress * 100 / progress.mOverallTotal) + "%");
    mProgressFraction.setText(
        Helpers.getDownloadProgressString(progress.mOverallProgress, progress.mOverallTotal));
  }
 private void setCurrentView(int currentView, boolean forceRefresh) {
   long timeInMillis = this.mCalendar.getTimeInMillis();
   switch (currentView) {
     case VIEW_DATE_PICKER_MONTH_DAY:
       ObjectAnimator monthDayAnim = Utils.getPulseAnimator(this.mMonthAndDayView, 0.9F, 1.05F);
       if (this.mDelayAnimation) {
         monthDayAnim.setStartDelay(500L);
         this.mDelayAnimation = false;
       }
       this.mDayPickerView.onDateChanged();
       if (this.mCurrentView != currentView || forceRefresh) {
         this.mMonthAndDayView.setSelected(true);
         this.mYearView.setSelected(false);
         this.mAnimator.setDisplayedChild(VIEW_DATE_PICKER_MONTH_DAY);
         this.mCurrentView = currentView;
       }
       monthDayAnim.start();
       String monthDayDesc =
           DateUtils.formatDateTime(getActivity(), timeInMillis, DateUtils.FORMAT_SHOW_DATE);
       this.mAnimator.setContentDescription(this.mDayPickerDescription + ": " + monthDayDesc);
       return;
     case VIEW_DATE_PICKER_YEAR:
       ObjectAnimator yearAnim = Utils.getPulseAnimator(this.mYearView, 0.85F, 1.1F);
       if (this.mDelayAnimation) {
         yearAnim.setStartDelay(500L);
         this.mDelayAnimation = false;
       }
       this.mYearPickerView.onDateChanged();
       if (this.mCurrentView != currentView || forceRefresh) {
         this.mMonthAndDayView.setSelected(false);
         this.mYearView.setSelected(true);
         this.mAnimator.setDisplayedChild(VIEW_DATE_PICKER_YEAR);
         this.mCurrentView = currentView;
       }
       yearAnim.start();
       String dayDesc = YEAR_FORMAT.format(Long.valueOf(timeInMillis));
       this.mAnimator.setContentDescription(this.mYearPickerDescription + ": " + dayDesc);
   }
 }
Exemple #7
0
 private long getFlipDurationFromPreference() {
   String key = getString(R.string.key_anim_flip_duration_preference);
   return Long.parseLong(preferences.getString(key, "500"));
 }
  private List<Map<String, Object>> getData() {
    List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

    String linuxVer = cmd.executeCat("/proc/version");
    int pos = linuxVer.indexOf(" (");
    if (pos >= 0) {
      linuxVer = linuxVer.substring(0, pos);
    }
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("title", "Linux version");
    map.put("info", linuxVer);
    // map.put("no", 1);
    list.add(map);

    String cpuInfo = cmd.executeCat("/proc/cpuinfo");
    pos = cpuInfo.indexOf(": ");
    int pos2 = cpuInfo.indexOf("\n");
    cpuInfo = cpuInfo.substring(pos + 2, pos2);
    map = new HashMap<String, Object>();
    map.put("title", "Cpu info");
    map.put("info", cpuInfo);
    // map.put("no", 2);
    list.add(map);

    ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
    activityManager.getMemoryInfo(memInfo);
    String memStr = cmd.executeCat("/proc/meminfo");
    Pattern pattern = Pattern.compile("(\\d+)");
    Matcher match = pattern.matcher(memStr);
    if (match.find()) {
      int allMem = Integer.parseInt(match.group(1));
      memStr = "" + allMem / 1024;
    }
    map = new HashMap<String, Object>();
    map.put("title", "Memory");
    map.put(
        "info", "Total: " + memStr + " MB  Available: " + memInfo.availMem / 1024 / 1024 + " MB");
    // map.put("no", 3);
    list.add(map);

    String netInfo = getIp();
    if (netInfo == null) {
      netInfo = cmd.execute(new String[] {"/system/bin/netcfg"});
      if (netInfo.length() > 0) {
        netInfo = netInfo.substring(0, netInfo.length() - 1);
      }
    }
    map = new HashMap<String, Object>();
    map.put("title", "Network");
    map.put("info", netInfo);
    // map.put("no", 4);
    list.add(map);

    map = new HashMap<String, Object>();
    map.put("title", "Screen");
    map.put("info", getDisplayMetrics());
    // map.put("no", 5);
    list.add(map);

    cpuInfo = cmd.executeCat("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq");
    //		Log.v("Hardware Activity", "cpu freq=" + cpuInfo);
    long cpuFreq = -1;
    try {
      cpuInfo = cpuInfo.substring(0, cpuInfo.length() - 1);
      cpuFreq = Long.valueOf(cpuInfo);
    } catch (Exception e) {
    }
    map = new HashMap<String, Object>();
    map.put("title", "CPU Freq");
    map.put("info", cpuFreq > 0 ? (cpuFreq / 1000 + " MHz") : "unknow");
    // map.put("no", 6);
    list.add(map);

    map = new HashMap<String, Object>();
    map.put("title", "Battery");
    map.put("info", mLastBattery);
    // map.put("no", 7);
    list.add(map);

    long[] romInfo = getRomMemroy();
    map = new HashMap<String, Object>();
    map.put("title", "Rom info");
    map.put("info", "All: " + formatSize(romInfo[0]) + "  Available: " + formatSize(romInfo[1]));
    // map.put("no", 8);
    list.add(map);

    long[] cardInfo = getSDCardMemory();
    map = new HashMap<String, Object>();
    map.put("title", "SDCard info");
    map.put("info", "All: " + formatSize(cardInfo[0]) + "  Available: " + formatSize(cardInfo[1]));
    // map.put("no", 9);
    list.add(map);

    map = new HashMap<String, Object>();
    map.put("title", "Mac Address");
    map.put("info", getMacAddress());
    // map.put("no", 10);
    list.add(map);

    map = new HashMap<String, Object>();
    map.put("title", "Startup ElapsedTime");
    map.put("info", getStartupElapsedTimes());
    // map.put("no", 11);
    list.add(map);

    Runtime runtime = Runtime.getRuntime();
    int maxMemory = ((int) runtime.maxMemory()) / 1024 / 1024;
    // 应用程序已获得内存
    long totalMemory = ((int) runtime.totalMemory()) / 1024 / 1024;
    // 应用程序已获得内存中未使用内存
    long freeMemory = ((int) runtime.freeMemory()) / 1024 / 1024;

    ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    int heapMemory = am.getMemoryClass();
    int largeHeapMemory = am.getLargeMemoryClass();
    //        /system/build.prop  dalvik.vm.heapstartsize dalvik.vm.heapgrowthlimit
    // dalvik.vm.heapsize=512m
    map = new HashMap<String, Object>();
    map.put("title", "App Memory");
    map.put(
        "info",
        String.format(
            Locale.getDefault(),
            "maxMemory=%dM, totalMemory=%dM, freeMemory=%dM, heapMemory=%dM, largeHeapMemory=%dM(可能还是heap, 待验证)",
            maxMemory,
            totalMemory,
            freeMemory,
            heapMemory,
            largeHeapMemory));
    // map.put("no", 12);
    list.add(map);

    return list;
  }