コード例 #1
0
ファイル: Task.java プロジェクト: fatroshi/FunToLearnV2
  /**
   * Download resources if needed and save item/category info in the database.
   *
   * @param params
   * @return
   */
  @Override
  protected List<Item> doInBackground(String... params) {
    String content = HttpManager.getDate(params[0]);
    // Get all parsed items
    List<Item> items = ItemJSONParser.parseFeed(content);

    if (items.size() == 0) {
      Log.i(TAG, "No update needed");
    } else {

      // Get image for each item
      for (Item item : items) {
        // Download item image and set
        Bitmap bitmap = ImageDownloader.download(this.SITE_URL + item.getImgLink());
        item.setBitmap(bitmap);

        // Save file to internal storage
        ImageDownloader.saveToInternalStorage(this.mainActivity, item);
        // Save items info in database
        this.db.addItem(item);
        // Save category if new
        if (!this.db.categoryExists(item.getCategoryId())) {
          this.db.addCategory(item);
        }
      }
    }
    return null;
  }
コード例 #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.facebook);

    //	필요한 위젯들 전부 로딩
    faceBook_myTitleTxtVw = (TextView) findViewById(R.id.faceBook_movieTitle);
    faceBook_myWhenTxtVw = (TextView) findViewById(R.id.faceBook_myWhenTxtVw);
    faceBook_myWhereTxtVw = (TextView) findViewById(R.id.faceBook_myWhereTxtVw);
    faceBook_myWithTxtVw = (TextView) findViewById(R.id.faceBook_myWhoTxtVw);
    faceBook_myGenreTxtVw = (TextView) findViewById(R.id.faceBook_myGenreTxtVw);
    faceBook_myOpenInfoTxtVw = (TextView) findViewById(R.id.faceBook_myOpenInfoTxtVw);
    faceBook_myActorTxtVw = (TextView) findViewById(R.id.faceBook_myActorTxtVw);
    faceBook_myDirectorTxtVw = (TextView) findViewById(R.id.faceBook_myDirectorTxtVw);

    faceBook_myThumbnail = (ImageView) findViewById(R.id.faceBook_myThumbnail);
    faceBook_myRatingBar = (RatingBar) findViewById(R.id.faceBook_myRatingBar);

    //	전달받은 인텐트를 가져온다.
    Intent intent = getIntent();
    //	인텐트가 존재하면
    if (intent != null) {
      //	movie객체를 가져와서 데이터를 뿌려준다.
      Movie movie = (Movie) intent.getSerializableExtra("movie");
      this.movie = movie;

      faceBook_myTitleTxtVw.setText(movie.getTitle());
      String getWhen = movie.getWhen();
      String year = getWhen.substring(0, 4);
      String month = getWhen.substring(4, 5);
      String day = getWhen.substring(5, 7);
      faceBook_myWhenTxtVw.setText(year + "년 " + month + "월 " + day + "일");
      faceBook_myWithTxtVw.setText(movie.getWith());
      faceBook_myWhereTxtVw.setText(movie.getWhere());
      rating =
          (float) ((movie.getGrade().equals("")) ? 0.0 : Float.parseFloat(movie.getGrade()))
              / (float) 2.0;
      faceBook_myRatingBar.setRating(rating);
      faceBook_myGenreTxtVw.setText("		● 장르 : " + movie.getGenre());
      faceBook_myActorTxtVw.setText("		● 감독 : " + movie.getDirector());
      faceBook_myActorTxtVw.setText("		● 배우 : " + Arrays.toString(movie.getActor()));
      faceBook_myOpenInfoTxtVw.setText("		● 개봉일 : " + movie.getOpenInfo());

      imageDownloader.download(movie.getThumbnail(), faceBook_myThumbnail);
    }

    mEtContent = (EditText) findViewById(R.id.faceBook_etContent);
    mBtnFeed = (Button) findViewById(R.id.faceBook_btnFeed);
    mBtnFeed.setOnClickListener(this);
    faceBook_btnLogout = (Button) findViewById(R.id.faceBook_btnLogout);
    faceBook_btnLogout.setOnClickListener(this);

    mFacebookAccessToken = getAppPreferences(this, "ACCESS_TOKEN");
    if (!mFacebookAccessToken.equals("")) {
      mFacebook.setAccessToken(mFacebookAccessToken);
    }
  }
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   ViewHolder holder;
   if (convertView == null) {
     convertView = li.inflate(R.layout.galleryitem, null);
     holder = new ViewHolder();
     holder.iv = (ImageView) convertView.findViewById(R.id.galleryitem_iv);
     convertView.setTag(holder);
   } else {
     holder = (ViewHolder) convertView.getTag();
   }
   imageDownloader.download(ConstantBean.ROOT + urls[position], holder.iv);
   return convertView;
 }