コード例 #1
0
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_image_gallery, container, false);
    final TParkInfo_LocEntity tParkInfo_LocEntity =
        (TParkInfo_LocEntity) getActivity().getIntent().getSerializableExtra("parkinfo");
    ; // 从当前Activity中获得
    imageUrls = new String[tParkInfo_LocEntity.parkInfo.imgUrlArray.size()];

    options =
        new DisplayImageOptions.Builder()
            .showImageOnLoading(R.drawable.ic_stub)
            .showImageForEmptyUri(R.drawable.ic_empty)
            .showImageOnFail(R.drawable.ic_empty)
            .cacheInMemory(true)
            .cacheOnDisc(true)
            .considerExifParams(true)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .build();

    Gallery gallery = (Gallery) view.findViewById(R.id.gallery);

    gallery.setAdapter(new ImageGalleryAdapter());
    gallery.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            startImagePagerActivity(position);
          }
        });
    return view;
  }
コード例 #2
0
  /** Called when the activity is first created. */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
    currentView = 0;

    mGestureSensor = new CameraGestureSensor(this);
    mGestureSensor.addGestureListener(this);
    mGestureSensor.enableClickByColor(true);
    mGestureSensor.addClickListener(this);

    mOpenCVInitiated = false;

    imageView = (ImageView) findViewById(R.id.ImageView01);
    imageView.setImageResource(pics[currentView]);

    ga = (Gallery) findViewById(R.id.Gallery01);
    ga.setAdapter(new ImageAdapter(this));
    ga.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapter, View givenView, int index, long arg3) {
            Toast.makeText(getBaseContext(), "A click was recieved!", Toast.LENGTH_SHORT).show();
            imageView.setImageResource(pics[index]);
            currentView = index;
          }
        });
  }
コード例 #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_goods_info);

    // 取得传过来的map对象
    map = App.map;
    init();

    getDetail(); // 获取数据

    DetailAdapter adapter = new DetailAdapter(list, this);
    g.setAdapter(adapter);
    g.setSelection(0);
    g.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            /*
             * 自定义dailog CustomDialog dia = new
             * CustomDialog(GoodsInfoActivity.this, list,
             * R.style.custom_dialog); dia.setPosition(position);
             * dia.show();
             */

            Intent i = new Intent(GoodsInfoActivity.this, ShowActivity.class);
            i.putExtra("position", position);
            i.putExtra("Arr", pathArr);
            i.putExtra("id", 1);
            startActivity(i);
            overridePendingTransition(R.anim.alpha_before, R.anim.alpha_ago);
          }
        });
  }
コード例 #4
0
    private void ini() {
      setWidth(LayoutParams.MATCH_PARENT);
      setHeight(LayoutParams.MATCH_PARENT);
      setAnimationStyle(R.style.popupwindow_anim);
      gallery = (Gallery) resource.findViewById(R.id.img_show_gallery);
      postionTV = (TextView) resource.findViewById(R.id.img_show_pos);
      galleryAdapter = new GalleryAdapter();
      gallery.setAdapter(galleryAdapter);
      gallery.setSelection(pos, true);
      postionTV.setText(pos + 1 + "/" + imgList.size());
      gallery.setOnItemClickListener(
          new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
              ImgShow.this.dismiss();
              IsImgShow = false;
            }
          });
      gallery.setOnItemSelectedListener(
          new OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
              postionTV.setText(position + 1 + "/" + imgList.size());
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {}
          });
    }
コード例 #5
0
 public ImageGallery(ComponentContainer container, String[] picnames, int[] basestyle) {
   super(container);
   view = new Gallery(container.$context());
   adapter = new ImageAdapter(container.$context(), basestyle);
   adapter.setFiles(picnames);
   view.setAdapter(adapter);
   view.setOnItemClickListener(this);
   container.$add(this);
   view.requestLayout();
 }
コード例 #6
0
 public ImageGallery(
     ComponentContainer container, String[] picnames, int[] basestyle, int resourceId) {
   super(container, resourceId);
   view = null;
   Gallery view = (Gallery) container.$form().findViewById(resourceId);
   adapter = new ImageAdapter(container.$context(), basestyle);
   adapter.setFiles(picnames);
   view.setAdapter(adapter);
   view.setOnItemClickListener(this);
   view.requestLayout();
 }
コード例 #7
0
 @Override
 public void onActivityCreated(Bundle savedInstanceState) {
   mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
   super.onActivityCreated(savedInstanceState);
   mAdapter = new ImagesAdapter(getApplication());
   mGallery.setAdapter(mAdapter);
   mGallery.setOnItemClickListener(this);
   mLoadImagesIndicator.setOnClickListener(this);
   if (mData.size() > 0
       && mPreferences.getBoolean(PREFERENCE_KEY_LOAD_MORE_AUTOMATICALLY, false)) {
     show();
   }
 }
コード例 #8
0
ファイル: ACDsee.java プロジェクト: WNJXYK/ClothesHeart
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.image);
		title=(TextView) findViewById(R.id.logo);
		
		
		GameSave = getSharedPreferences("cn.Arthur.Game.ClothesHeartCG", 0);
		ReadTimes = GameSave.getInt("ReadTimes", 0);
		if (ReadTimes>1000) isUnlock=true;
		ImageList = getImagesFromSD();
		
		/**
		 * xml获取Switcher 
		 */
		mSwitcher = (ImageSwitcher) findViewById(R.id.switcher);
		mSwitcher.setFactory(this);

		mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this,
				android.R.anim.slide_in_left));

		mSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this,
				android.R.anim.slide_out_right));

		/**
		 * xml获取Gallery
		 */
		Gallery g = (Gallery) findViewById(R.id.mygallery);

		
		if(ImageList == null || ImageList.size() == 0)
			return;
		
		/**
		 * 创建适配器,注册适配器
		 */
		g.setAdapter(new ImageAdapter(this, ImageList));

		g.setOnItemSelectedListener(this);

		/**
		 * 点击事件监听器
		 */
		g.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View v,
					int position, long id) {
				
			}
		});
		SpotManager.getInstance(this).showSpotAds(this);
	}
コード例 #9
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_image_switcher);

    imageSwitcher = (ImageSwitcher) findViewById(R.id.switcher);
    imageSwitcher.setFactory(this);
    imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in));
    imageSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));

    Gallery gallery = (Gallery) findViewById(R.id.gallery);
    gallery.setAdapter(new ImageAdapter(getBaseContext()));
    gallery.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            imageSwitcher.setImageResource(imageIDs[position]);
          }
        });
  }
コード例 #10
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_photo);
    Gallery g = (Gallery) findViewById(R.id.gallery);

    // 添加一个ImageAdapter并设置给Gallery对象
    g.setAdapter(new ImageAdapter(this, getSD()));

    // 设置一个itemclickListener事件
    g.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // TODO Auto-generated method stub

          }
        });
  }
コード例 #11
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.galleryactivity);

    Gallery gallery = (Gallery) findViewById(R.id.gallery1);
    selectedImage = (ImageView) findViewById(R.id.imageView1);
    gallery.setSpacing(1);
    gallery.setAdapter(new GalleryImageAdapter(this));

    // clicklistener for Gallery
    gallery.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            // TODO Auto-generated method stub
            // Toast.makeText(GalleryActivity.this, "Your selected position = " + position,
            // Toast.LENGTH_SHORT).show();
            // show the selected Image
            selectedImage.setImageResource(mImageIds[position]);
          }
        });
  }
コード例 #12
0
  public RaceSelectionGallery(Context context, int[] races, final Selector selector) {
    super(context);
    this.context = context;
    this.selections = new boolean[races.length];
    int[] ids = new int[races.length];
    for (int i = 0; i < races.length; i++) {
      ids[i] = ResourceUtilities.getIconID(Races.getName(races[i]));
    }
    super.setAdapter(new ImageAdapter(ids));
    super.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selections[position] = !selections[position];

            selector.onSelection(selections);

            for (int i = 0; i < selections.length; i++) {
              images[i].setAlpha((selections[i] ? SELECTED : NOT_SELECTED));
            }
          }
        });
  }
コード例 #13
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    // Lookup R.layout.main
    LinearLayout layout = (LinearLayout) findViewById(R.id.admoblayout);

    // Create the adView
    // Please replace MY_BANNER_UNIT_ID with your AdMob Publisher ID
    AdView adView = new AdView(this, AdSize.BANNER, "a14e9304811c39d");

    // Add the adView to it
    layout.addView(adView);

    // Initiate a generic request to load it with an ad
    AdRequest request = new AdRequest();
    request.setTesting(true);

    adView.loadAd(request);
    position = 0;
    imgView = (ImageView) findViewById(R.id.ImageView01);
    imgView.setImageResource(Imgid[0]);

    gallery = (Gallery) findViewById(R.id.liquidgallery);
    gallery.setAdapter(new AddImgAdp(this));

    gallery.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(
              @SuppressWarnings("rawtypes") AdapterView parent, View v, int position, long id) {
            imgView.setImageResource(Imgid[position]);
            LiquidBackgroundsFreeActivity.this.position = position;
          }
        });

    imgView.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {

            AlertDialog alertDialog =
                new AlertDialog.Builder(LiquidBackgroundsFreeActivity.this).create();
            alertDialog.setTitle(Messages.getString("DIA_NUM.0")); // $NON-NLS-1$
            alertDialog.setMessage(Messages.getString("DIA_NUM.1")); // $NON-NLS-1$
            alertDialog.setButton(
                Messages.getString("DIA_NUM.2"), // $NON-NLS-1$
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {

                    Bitmap bitmap = BitmapFactory.decodeResource(getResources(), Imgid[position]);
                    try {
                      LiquidBackgroundsFreeActivity.this.setWallpaper(bitmap);
                    } catch (IOException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                    }
                    Log.d(
                        Messages.getString("DIA_NUM.3"),
                        Messages.getString("DIA_NUM.4")); // $NON-NLS-1$ //$NON-NLS-2$
                  }
                });

            alertDialog.show();
            return true;
          }
        });
  }
コード例 #14
0
  /** 初始化可左右滑动的图片Adapter */
  private void initPicAdapter(String imgs[]) {
    for (int i = 0; i < imgs.length; i++) {
      ImageView iv = new ImageView(getBaseContext());
      LayoutParams lp = (LayoutParams) iv.getLayoutParams();
      if (null == lp) {
        lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      }
      iv.setImageResource(R.drawable.dot_grey2x);
      lp.rightMargin = 5;
      iv.setLayoutParams(lp);
      frame_dian.addView(iv);
      imgViews.add(iv);
    }

    for (int h = 0; h < imgs.length; h++) {
      ImageView imageView_pic = new ImageView(this);
      String url = imgs[h];
      bitmapUtilsPic.display(imageView_pic, url);
      viewlist.add(imageView_pic);
    }

    if (null == picAdapter) {
      picAdapter = new GroupBuyImageAdapter(PindanDetailActivity.this, imgs);
      gallery.setAdapter(picAdapter);
      gallery.setSelection(0);
      gallery.setOnItemClickListener(
          new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
              // 不显示大图片
              if (null == pagerAdapter) {
                pagerAdapter = new BigPicAdapter(viewlist, handler);
                pagerImage.setAdapter(pagerAdapter);
              }
              pagerImage.setCurrentItem(position);
              content_all.setVisibility(View.INVISIBLE);
              pagerLayout.setVisibility(View.VISIBLE);
              pagerLayout.startAnimation(animationsmall_big);
            }
          });
      gallery.setOnItemSelectedListener(
          new OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3) {

              for (int i = 0; i < imgViews.size(); i++) {
                if (i == position) {
                  ((ImageView) frame_dian.getChildAt(i)).setImageResource(R.drawable.dot_yellow2x);
                } else {
                  ((ImageView) frame_dian.getChildAt(i)).setImageResource(R.drawable.dot_grey2x);
                }
              }
            }

            @Override
            public void onNothingSelected(AdapterView<?> arg0) {}
          });
    } else {
      picAdapter.notifyDataSetChanged();
    }
  }
コード例 #15
0
  private void setListener() {
    mCancel.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            // 关闭当前界面
            finish();
          }
        });
    mUpload.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            // 判断手机相册界面是否关闭,如果没关闭则关闭
            if (!PhoneAlbumActivity.mInstance.isFinishing()) {
              PhoneAlbumActivity.mInstance.finish();
            }
            // 显示提示信息并关闭当前界面
            Toast.makeText(PhotoShareActivity.this, "上传图片成功", Toast.LENGTH_SHORT).show();
            finish();
          }
        });
    mDisplay.setOnItemClickListener(
        new OnItemClickListener() {

          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // 获取当前的照片编号以及照片地址传递到照片编辑类
            mCurrentPosition = arg2;
            mCurrentPath = mKXApplication.mAlbumList.get(mCurrentPosition).get("image_path");
            Intent intent = new Intent();
            intent.setClass(PhotoShareActivity.this, ImageFilterActivity.class);
            intent.putExtra("path", mCurrentPath);
            intent.putExtra("isSetResult", true);
            startActivityForResult(intent, 0);
          }
        });
    mDisplaySingle.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            // 将照片地址传递到照片编辑类
            Intent intent = new Intent();
            intent.setClass(PhotoShareActivity.this, ImageFilterActivity.class);
            intent.putExtra("path", mCurrentPath);
            intent.putExtra("isSetResult", true);
            startActivityForResult(intent, 0);
          }
        });
    mLocation.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            // 显示地理位置对话框
            locationDialog();
          }
        });
    mDelete.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            // 更换显示,设置地理位置编号
            mLocation.setText("选择当前位置");
            mLocationPosition = -1;
          }
        });
    mAlbum.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            // 相册对话框
            AlbumDialog();
          }
        });
  }
コード例 #16
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.incident_view);
    mapView = (MapView) findViewById(R.id.loc_map);
    Bundle incidents = getIntent().getExtras();

    extras = incidents.getBundle("incidents");
    reportLatitude = extras.getString("latitude");
    reportLongitude = extras.getString("longitude");
    id = extras.getInt("id");

    String iStatus =
        Util.toInt(extras.getString("status")) == 0
            ? getString(R.string.status_no)
            : getString(R.string.status_yes);
    title = (TextView) findViewById(R.id.title);
    title.setTypeface(Typeface.DEFAULT_BOLD);
    title.setText(extras.getString("title"));

    activityTitle = (TextView) findViewById(R.id.title_text);
    if (activityTitle != null) activityTitle.setText(getTitle());

    category = (TextView) findViewById(R.id.category);
    category.setTextColor(Color.BLACK);
    category.setText(extras.getString("category"));

    date = (TextView) findViewById(R.id.date);
    date.setTextColor(Color.BLACK);
    date.setText(extras.getString("date"));

    location = (TextView) findViewById(R.id.location);
    location.setTextColor(Color.BLACK);
    location.setText(extras.getString("location"));

    body = (TextView) findViewById(R.id.webview);
    body.setTextColor(Color.BLACK);
    body.setText(extras.getString("desc"));

    status = (TextView) findViewById(R.id.status);
    status.setText(iStatus);

    media = extras.getString("media");

    image = extras.getString("image");

    imageAdapter = new ImageAdapter(this);

    thumbnailAdapter = new ImageAdapter(this);

    mSwitcher = (ImageSwitcher) findViewById(R.id.switcher);
    mSwitcher.setFactory(this);
    mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in));
    mSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));

    if (!media.equals("")) {

      thumbnails = media.split(",");
      for (int i = 0; i < thumbnails.length; i++) {
        thumbnailAdapter.mImageIds.add(ImageManager.getImages(Preferences.savePath, thumbnails[i]));
      }

      images = image.split(",");

      for (int i = 0; i < images.length; i++) {

        imageAdapter.mImageIds.add(ImageManager.getImages(Preferences.savePath, images[i]));
      }

    } else {
      photos = (TextView) findViewById(R.id.report_photo);
      photos.setText("");
    }

    Gallery g = (Gallery) findViewById(R.id.gallery);

    g.setAdapter(thumbnailAdapter);
    g.setOnItemSelectedListener(this);
    g.setOnItemClickListener(
        new OnItemClickListener() {

          public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
            previewImage(position);
          }
        });
    mapController = mapView.getController();
    defaultLocation =
        getPoint(Double.parseDouble(reportLatitude), Double.parseDouble(reportLongitude));
    centerLocation(defaultLocation);
  }
コード例 #17
0
ファイル: Hymne.java プロジェクト: kiof/Hymne
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mContext = this.getApplicationContext();
    Resources mResources = this.getResources();
    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);

    /* mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    // Register NMEA listener
    if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        int TAG_CODE_PERMISSION_FINE_LOCATION = 1;
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, TAG_CODE_PERMISSION_FINE_LOCATION);
        return;
    }

    if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
        createNmeaListener();
        // mLocationManager.addNmeaListener(mNmeaListener);
    }*/

    // Launch Sntp request
    createSntp();

    setContentView(R.layout.main);

    // AdMob
    MobileAds.initialize(getApplicationContext(), getString(R.string.ad_unit_id));
    AdView adView = (AdView) this.findViewById(R.id.adView);
    AdRequest adRequest =
        new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            //                .addTestDevice("53356E870D99B80A68F8E2DBBFCD28FB")
            .build();
    adView.loadAd(adRequest);

    mViewSwitcher = (ViewSwitcher) findViewById(R.id.profileSwitcher);

    // Get Preferences
    PreferenceManager.setDefaultValues(this, R.xml.setting, false);
    myCountry = mSharedPreferences.getInt(MY_COUNTRY, -1);

    countries = mResources.getStringArray(R.array.countries);
    flags = mResources.obtainTypedArray(R.array.flags);
    sounds = mResources.obtainTypedArray(R.array.sounds);

    Gallery gallery = (Gallery) findViewById(R.id.gallery);
    gallery.setAdapter(new ImageAdapter(this));

    gallery.setOnItemClickListener(
        new OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            setMyFlag(position);
          }
        });

    if (myCountry >= 0) setMyFlag(myCountry);

    // Display change log if new version
    ChangeLog cl = new ChangeLog(this);
    if (cl.firstRun())
      new HtmlAlertDialog(
              this,
              R.raw.about,
              getString(R.string.about_title),
              android.R.drawable.ic_menu_info_details)
          .show();

    // Audio management for initVolume control
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    // Propose to set initVolume to max if it is not loud enough
    initVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
    int maxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    if (mSharedPreferences.getBoolean(CHECK_VOLUME, false)) {
      if ((2 * initVolume / maxVolume) < 1) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.volume_title);
        builder.setIcon(android.R.drawable.ic_menu_preferences);
        builder.setMessage(R.string.volume_question);
        builder.setNegativeButton(R.string.volume_no, null);
        builder.setPositiveButton(
            R.string.volume_yes,
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                mAudioManager.setStreamVolume(
                    AudioManager.STREAM_MUSIC,
                    mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC),
                    AudioManager.FLAG_SHOW_UI);
              }
            });
        builder.create();
        builder.show();
      }
    } else {
      if (mSharedPreferences.getBoolean(VOLUME_MAX, false)) {
        mAudioManager.setStreamVolume(
            AudioManager.STREAM_MUSIC,
            mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC),
            AudioManager.FLAG_SHOW_UI);
      }
    }
  }
コード例 #18
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    /*设定图片*/
    Integer[] myImageIds = {
      R.drawable.google,
      R.drawable.helloking,
      R.drawable.chamberlain,
      R.drawable.king,
      R.drawable.with,
    };
    mImageAdapter01 = new ImageAdapter(EX05_13.this, myImageIds);
    /*设定图为Gallery的显示方式*/
    Gallery g = (Gallery) findViewById(R.id.mygallery);
    g.setAdapter(mImageAdapter01);
    g.setOnItemClickListener(
        new Gallery.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View v, final int position, long id) {
            // TODO Auto-generated method stub
            new AlertDialog.Builder(EX05_13.this)
                .setTitle(R.string.app_about)
                /*设定弹出窗口的图式*/
                .setIcon(mImageAdapter01.myImageIds[position])
                /*设定弹出窗口的讯息*/
                .setMessage(R.string.app_about_msg)
                /*确认窗口*/
                .setPositiveButton(
                    R.string.str_ok,
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialoginterface, int i) {
                        Resources resources = getBaseContext().getResources();
                        is = resources.openRawResource(mImageAdapter01.myImageIds[position]);
                        try {
                          /*更换桌布*/
                          setWallpaper(is);
                          /*用Toast来显示桌布已更换*/
                          Toast.makeText(
                                  EX05_13.this,
                                  getString(R.string.my_gallery_text_pre),
                                  Toast.LENGTH_SHORT)
                              .show();
                        } catch (Exception e) {
                          e.printStackTrace();
                        }
                        ;
                      }
                    })
                /*设定跳出窗口的返回事件*/
                .setNegativeButton(
                    R.string.str_no,
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialoginterface, int i) {

                        /*用Toast来显示桌布已取消*/
                        Toast.makeText(
                                EX05_13.this,
                                getString(R.string.my_gallery_text_no),
                                Toast.LENGTH_SHORT)
                            .show();
                      }
                    })
                .show();
          }
        });
  }
コード例 #19
0
ファイル: ThesisActivity.java プロジェクト: npfitz/Thesis
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    adpt = new GalleryAdapter(this);
    pics = new Vector<Image>();

    previews = (Gallery) findViewById(R.id.gallery1);
    Main = (ImageView) findViewById(R.id.PictureView);
    hist = (Histogram) findViewById(R.id.histogram);
    saturation = (SeekBar) findViewById(R.id.saturation);
    contrast = (SeekBar) findViewById(R.id.contrast);
    exposure = (SeekBar) findViewById(R.id.exposure);
    saveButton = (Button) findViewById(R.id.save);

    contrast.setProgress(50);
    exposure.setProgress(50);
    saturation.setProgress(100);

    handler = new UIHandler(Main, hist);
    tm = new ThreadManager(handler);
    save = new Save();
    save.setContainer(Main);

    PinchyZoomy pz = new PinchyZoomy();

    Main.setOnTouchListener(pz);
    Main.setDrawingCacheEnabled(true);
    Main.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);

    File folder = new File("/sdcard");

    for (int i = 0; i < folder.listFiles().length; i++) {
      String name = folder.listFiles()[i].getName();
      if (folder.listFiles()[i].isFile()) {
        String extension = name.substring(name.length() - 3);
        if (extension.equals("NEF") || extension.equals("dng")) {
          Image temp = new Image(folder.listFiles()[i].getAbsolutePath());
          pics.add(temp);
        }
      }
    }

    for (int i = 0; i < pics.size(); i++) {
      System.out.println("Pulling thumb for: " + pics.elementAt(i).path);
      adpt.addImage(pics.elementAt(i).getThumb());
    }

    previews.setAdapter(adpt);
    previews.setSpacing(3);

    previews.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Main.setImageBitmap(adpt.getItemAt(position));
            Main.setAlpha(100);

            if (current != null) current.free();

            current = pics.elementAt(position);
            handler.setImage(current);
            tm.pic = current;
            save.setImage(current);

            contrast.setProgress(50);
            exposure.setProgress(50);
            saturation.setProgress(100);

            LoadImageThread t = new LoadImageThread(current, handler);
            t.start();
          }
        });

    saturation.setOnSeekBarChangeListener(
        new OnSeekBarChangeListener() {

          @Override
          public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {

            if (current.colors != null) tm.setSaturation(saturation.getProgress());
          }

          @Override
          public void onStartTrackingTouch(SeekBar arg0) {}

          @Override
          public void onStopTrackingTouch(SeekBar arg0) {}
        });
    contrast.setOnSeekBarChangeListener(
        new OnSeekBarChangeListener() {

          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (current.colors != null) tm.setContrast(contrast.getProgress());
          }

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

          }
        });
    exposure.setOnSeekBarChangeListener(
        new OnSeekBarChangeListener() {

          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (current.colors != null) tm.setExposure(exposure.getProgress());
          }

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

          }
        });

    saveButton.setOnClickListener(save);
  }
コード例 #20
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.call_activity_contact_layout);

    tts = new TTS(this);
    tts.init();

    myPager = (ViewPager) findViewById(R.id.contact_viewpager);
    myGallery = (Gallery) findViewById(R.id.contact_gallery);
    resolve();
    initPagerItems();
    myPagerAdapter = new MyPagerAdapter();
    myGalleryAdapter = new MyGalleryAdapter(this);
    myPager.setAdapter(myPagerAdapter);
    myGallery.setAdapter(myGalleryAdapter);

    myGallery.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            myPagerAdapter.notifyDataSetChanged();
            myPager.setCurrentItem(position % bitmapList.size());

            currentIndex = position % bitmapList.size();
          }
        });

    myGallery.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
            myPagerAdapter.notifyDataSetChanged();
            myPager.setCurrentItem(position % bitmapList.size());
            currentIndex = position % bitmapList.size();
          }

          @Override
          public void onNothingSelected(AdapterView<?> adapterView) {}
        });

    myPager.setOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(int i, float v, int i2) {
            if (i != currentPager) {

              Log.v("pager", i + "  ");

              // TODO: tts
              String contentToRead = nameList.get(i);
              tts.getsSpeechSynthesizer().startSpeaking(contentToRead, null);

              currentPager = i;
            }
          }

          @Override
          public void onPageSelected(int i) {

            currentIndex = i;
            myGallery.setSelection(i);
          }

          @Override
          public void onPageScrollStateChanged(int i) {}
        });
  }