Example #1
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   String courseMsg = getItem(position);
   View view = LayoutInflater.from(getContext()).inflate(itemViewId, null);
   RelativeLayout courseListItem = (RelativeLayout) view.findViewById(R.id.course_list_item);
   TextView courseNumber = (TextView) view.findViewById(R.id.course_number);
   TextView coursePlace = (TextView) view.findViewById(R.id.course_place);
   TextView courseName = (TextView) view.findViewById(R.id.course_name);
   courseListItem.getBackground().setAlpha(100);
   courseNumber.getBackground().setAlpha(100);
   int num = position + 1;
   String number = "" + num;
   courseNumber.setText(number);
   coursePlace.setText(courseMsg.split("@")[0]);
   courseName.setText(courseMsg.split("@")[1]);
   return view;
 }
Example #2
0
 @Override
 protected void onDestroy() {
   // TODO Auto-generated method stub
   super.onDestroy();
   this.setContentView(R.layout.view_null);
   /////////////////
   BitmapDrawable bd = (BitmapDrawable) allLayout.getBackground();
   allLayout.setBackgroundResource(0); // 别忘了把背景设为null,避免onDraw刷新背景时候出现used a recycled bitmap错误
   bd.setCallback(null);
   bd.getBitmap().recycle();
   allLayout = null;
   /////////////////
   btnPersonal = null;
   btnExpert = null;
   btnMessage = null;
   /////////////////
 }
 public void setImage(String bitmapLocation) {
   this.bitmapLocation = bitmapLocation;
   if (bitmapLocation == null || bitmapLocation.equals("")) return;
   Bitmap backgroundBitmap =
       ImageTools.decodeFile(
           bitmapLocation,
           DisplayUtils
               .dispayWidth); // BitmapFactory.decodeFile(bitmapLocation,
                              // ImageTools.getDefaultBitmapOptions());
   BitmapDrawable background = (BitmapDrawable) topLayout.getBackground();
   topLayout.setBackgroundDrawable(
       new BitmapDrawable(
           ImageTools.resizeBitmapToFitExactlyInBox(
               backgroundBitmap,
               DisplayUtils.getDpiSpecificValue(background.getMinimumWidth()),
               DisplayUtils.getDpiSpecificValue(background.getMinimumHeight()))));
   Utils.recycle(backgroundBitmap);
   hideWidgets();
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_action);

    // Set the action to null, this indicates that it has not been fetched
    mAction = null;

    // Fetch UI components
    RelativeLayout circleView = (RelativeLayout) findViewById(R.id.action_circle_view);
    mActionImage = (ImageView) findViewById(R.id.action_image);
    mActionTitle = (TextView) findViewById(R.id.action_title);
    mActionDescription = (TextView) findViewById(R.id.action_description);
    mExternalResourceHeader = (TextView) findViewById(R.id.action_external_resource_header);
    mExternalResource = (TextView) findViewById(R.id.action_external_resource);
    mMoreInfoHeader = (TextView) findViewById(R.id.action_more_info_header);
    mMoreInfo = (TextView) findViewById(R.id.action_more_info);
    mTickSwitcher = (ViewSwitcher) findViewById(R.id.action_tick_switcher);

    // Animate the switcher.
    mTickSwitcher.setInAnimation(this, R.anim.action_switcher_fade_in);
    mTickSwitcher.setOutAnimation(this, R.anim.action_switcher_fade_out);

    // Listeners
    findViewById(R.id.action_later).setOnClickListener(this);
    findViewById(R.id.action_did_it).setOnClickListener(this);

    // Circle view
    GradientDrawable gradientDrawable = (GradientDrawable) circleView.getBackground();
    gradientDrawable.setColor(Color.WHITE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
      circleView.setBackground(gradientDrawable);
    } else {
      circleView.setBackgroundDrawable(gradientDrawable);
    }

    mActionComplete = false;

    fetchAction(getIntent().getIntExtra(ACTION_ID_KEY, -1));
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gallery_list);
    getSupportActionBar().hide();
    RelativeLayout galleryListRelativeLayout =
        (RelativeLayout) findViewById(R.id.galleryListRelativeLayout);
    galleryListRelativeLayout.setBackgroundResource(R.drawable.rsz_androids);
    galleryListRelativeLayout.getBackground().setAlpha(40);
    ArrayList galleryListArrayList = new ArrayList();
    galleryListArrayList.add("HK Photos");
    galleryListArrayList.add("Gaoming Photos");
    galleryListArrayList.add("Hour of Code Photos");
    ListView galleryListListView = (ListView) findViewById(R.id.galleryListListView);
    CustomList customAdapter = new CustomList(this, galleryListArrayList, imageId);
    galleryListListView.setAdapter(customAdapter);
    galleryListListView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (i == 0) {
              Intent intent = new Intent(GalleryList.this, HKPhotos.class);
              startActivity(intent);
            }
            if (i == 1) {
              Intent intent = new Intent(GalleryList.this, GaomingPhotos.class);
              startActivity(intent);
            }
            if (i == 2) {
              Intent intent = new Intent(GalleryList.this, Gallery.class);
              startActivity(intent);
            }
          }
        });

    ListView drawerListView = (ListView) findViewById(R.id.drawer_list);
    ArrayList drawerArrayList = new ArrayList();
    drawerArrayList.add("Objectives");
    drawerArrayList.add("Results");
    drawerArrayList.add("Workshop");
    drawerArrayList.add("Gallery");
    drawerListView.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, drawerArrayList));
    drawerListView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (i == 0) {
              Intent intent = new Intent(GalleryList.this, Objectives.class);
              startActivity(intent);
            }
            if (i == 1) {
              Intent intent = new Intent(GalleryList.this, Results.class);
              startActivity(intent);
            }
            if (i == 2) {
              Intent intent = new Intent(GalleryList.this, Workshop.class);
              startActivity(intent);
            }
            if (i == 3) {
              Toast.makeText(
                      GalleryList.this.getApplicationContext(),
                      "You are already in the gallery page",
                      Toast.LENGTH_SHORT)
                  .show();
              return;
            }
          }
        });
  }
Example #6
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.favorites);
    // View view = inflater.inflate(R.layout.favorites, null);
    /*ImageView left = (ImageView) view.findViewById(R.id.favorite_left);
    left.setOnClickListener(new View.OnClickListener() {
    	public void onClick(View v) {
    		//Log.d(TAG, "showLeft");
    		((MainActivity) getActivity()).showLeft();
    	}
    });
    */
    // userid
    userid = Global.getUserId();

    // progressDialog = ProgressDialog.show(getActivity(), "加载中", "请稍后,正在加载...");
    View toastRoot = getLayoutInflater().inflate(R.layout.progressbar_toast, null);
    // progressBar = (ProgressBar)toastRoot.findViewById(R.id.fprogressBar);
    // progressBar.setVisibility(View.VISIBLE);
    LoadingImageView progress = new LoadingImageView(getApplicationContext());
    RelativeLayout rl = (RelativeLayout) toastRoot.findViewById(R.id.progress_toast_layout);
    rl.getBackground().setAlpha(0);
    rl.addView(progress, 84, 84);
    toast = new Toast(getApplicationContext());
    toast.setView(toastRoot);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.setDuration(Toast.LENGTH_LONG);
    toast.show();

    buttonRL = (RelativeLayout) findViewById(R.id.fedit);
    deleteButton = (ImageTextButton) findViewById(R.id.fdelete);
    cancelButton = (ImageTextButton) findViewById(R.id.fcancel);
    deleteButton.setImgResource(R.drawable.clip_off);
    deleteButton.setText("限免信息推送");
    cancelButton.setImgResource(R.drawable.pencil);
    cancelButton.setText("编辑");
    deleteButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (ifdelete) {
              if (!deletefinish) {
                return;
              } else deletefinish = false;
              Log.e(TAG, "deleteinggggggggggggggg");
              NameValuePair pair0, pair1;
              String gameId, cid;
              boolean delete_success = true;
              int selectCount = 0;
              ArrayList<OneGameGame> sub = new ArrayList<OneGameGame>();
              HashMap<Integer, Boolean> allSelected = MyAdapter.getIsSelected();
              for (Integer i = 0; i < list.size(); i++) {
                if (!allSelected.get(i)) continue;
                sub.add(list.get(i));
                selectCount++;
                gameId = String.valueOf(list.get(i).getId());
                cid = String.valueOf(list.get(i).getCollect_num());
                pair0 = new BasicNameValuePair("id", cid);
                pair1 = new BasicNameValuePair("game_id", gameId);
                List<NameValuePair> data = new ArrayList<NameValuePair>();
                data.add(pair0);
                data.add(pair1);
                String str = HttpUtils.doPost(Global.COLLECT_CANCLECOLLECT, data);
                // System.out.println(str);
                try {
                  JSONObject json = new JSONObject(str);
                  String message = json.getString("message");
                  if (!message.equals("success")) delete_success = false;
                  Log.e(TAG, "delete Favorite game message: " + message);

                } catch (JSONException e) {
                  Log.e(TAG, "deleteFavoriteERROR");
                  e.printStackTrace();
                }
              }

              list.removeAll(sub);
              Log.e(
                  "xxxxxxxxxxx",
                  "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx: " + ((Integer) list.size()).toString());
              mAdapter.initData();
              mAdapter.notifyDataSetChanged();

              // View toastRoot = getLayoutInflater().inflate(R.layout.my_toast, null);

              String tv; // TextView tv = (TextView)toastRoot.findViewById(R.id.toast_text);
              if (delete_success) {
                if (selectCount != 0) tv = "删除成功!";
                else tv = "请选择!";
              } else tv = "删除失败!";
              // RelativeLayout rl = (RelativeLayout)toastRoot.findViewById(R.id.toast_layout);
              // rl.getBackground().setAlpha(50);
              Toast mytoast = Toast.makeText(getApplicationContext(), tv, Toast.LENGTH_SHORT);
              // mytoast.setView(toastRoot);
              mytoast.setGravity(Gravity.BOTTOM, 0, 0);
              mytoast.show();
              deletefinish = true;
              Log.e(TAG, "delete finisheddddddd");
            } else {
              Toast mytoast;
              if (isXianMianOn) {
                deleteButton.setImgResource(R.drawable.clip_off);
                mytoast = Toast.makeText(getApplicationContext(), "已关闭", Toast.LENGTH_SHORT);
              } else {
                deleteButton.setImgResource(R.drawable.clip_on);
                mytoast = Toast.makeText(getApplicationContext(), "已打开", Toast.LENGTH_SHORT);
              }

              isXianMianOn = !isXianMianOn;
              mytoast.setGravity(Gravity.BOTTOM, 0, 0);
              mytoast.show();
            }
          }
        });
    cancelButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            // handler.sendEmptyMessage(1);
            if (ifcancel) {
              // ArrayList<Integer> selectArr = mAdapter.getAllSelected();
              for (int i = 0; i < mAdapter.getCount(); i++) {
                View temp = favoritesList.getChildAt(i);
                if (temp != null) {
                  ViewHolder viewHolder = (ViewHolder) temp.getTag();
                  // viewHolder.cb.toggle();
                  viewHolder.cb.setVisibility(View.INVISIBLE);
                }
              }
              editmode = false;
              ifcancel = false;
              ifdelete = false;
              deleteButton.setImgResource(R.drawable.clip);
              deleteButton.setText("限免信息推送");
              cancelButton.setText("编辑");
              mAdapter.initData();
              // FavoritesFragment.handl_visible.sendEmptyMessage(0);
            } else {
              for (int i = 0; i < mAdapter.getCount(); i++) {
                View temp = favoritesList.getChildAt(i);
                if (temp != null) {
                  ViewHolder viewHolder = (ViewHolder) temp.getTag();
                  // viewHolder.cb.toggle();
                  viewHolder.cb.setVisibility(View.VISIBLE);
                }
              }
              editmode = true;
              ifcancel = true;
              ifdelete = true;
              deleteButton.setImgResource(R.drawable.delete);
              deleteButton.setText("删除");
              cancelButton.setText("取消编辑");
            }
          }
        });

    /*switcher = (Switch)view.findViewById(R.id.switch1);
    switcher.setOnCheckedChangeListener(new OnCheckedChangeListener(){
              @Override
              public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                  if (isChecked) {
                  	Log.d(TAG, "state is on");
                      //state is on
                  } else {
                  	Log.d(TAG, "state is off");
                      //state is off
                  }
              }
          });*/

    favoritesList = (GridView) findViewById(R.id.favorites_list);
    handl_getdata.sendEmptyMessage(1);
    mAdapter = new MyAdapter(list, favoritesList, getApplicationContext());
    favoritesList.setAdapter(mAdapter);
    favoritesList.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            if (editmode) {
              // 取得ViewHolder对象,这样就省去了通过层层的findViewById去实例化我们需要的cb实例的步骤
              ViewHolder holder = (ViewHolder) arg1.getTag();
              // 改变CheckBox的状态
              holder.cb.toggle();
              // 将CheckBox的选中状况记录下来
              // MyAdapter.getIsSelected().put(arg2, holder.cb.isChecked());
            } else {
              OneGameGame game = list.get(arg2);
              Bundle bundle = new Bundle();
              bundle.putSerializable("game", game);
              Intent i = new Intent(getApplicationContext(), DetailActivityForResult.class);
              i.putExtras(bundle);
              startActivity(i);
            }
          }
        });
  }
  @Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {

    super.onViewCreated(view, savedInstanceState);

    lowtxt = (TextView) view.findViewById(R.id.low);
    medtxt = (TextView) view.findViewById(R.id.medium);
    hightxt = (TextView) view.findViewById(R.id.high);
    name = (TextView) view.findViewById(R.id.description);
    priority = (TextView) view.findViewById(R.id.priority);
    date = (TextView) view.findViewById(R.id.startDate);
    type = (TextView) view.findViewById(R.id.type);
    noEvents = (TextView) view.findViewById(R.id.no_events);

    background = (RelativeLayout) view.findViewById(R.id.relBackground);

    barChart = (BarChart) view.findViewById(R.id.barchart);

    Calendar calendar = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyy HH:mm");
    String dat = sdf.format(calendar.getTime());
    String[] d = dat.split(" ");
    ArrayList<Event> events =
        DBConnector.getHelper(getActivity())
            .findEventsBetweenDateAndHours(d[0], d[0], d[1], " 23:59");

    Event event = null;
    if (events.size() > 0) {
      noEvents.setVisibility(View.GONE);
      background.setVisibility(View.VISIBLE);
      event = events.get(0);
      name.setText(event.getDescription());
      switch (Integer.parseInt(event.getPriority())) {
        case 1:
          priority.setText("low");
          break;
        case 2:
          priority.setText("medium");
          break;
        case 3:
          priority.setText("high");
          break;
      }

      type.setText(event.getType());
      date.setText(event.getStartDate() + " " + event.getStartHour());

      int bkColor =
          getActivity()
              .getResources()
              .getIdentifier(event.getColor(), "color", getActivity().getPackageName());
      GradientDrawable drawable = (GradientDrawable) background.getBackground();
      drawable.setColor(getActivity().getResources().getColor(bkColor));
    } else {
      background.setVisibility(View.GONE);
      noEvents.setVisibility(View.VISIBLE);
    }

    int lowCount = 0, medCount = 0, highCount = 0;

    for (Event e : events) {
      switch (Integer.parseInt(e.getPriority())) {
        case 1:
          lowCount++;
          break;
        case 2:
          medCount++;
          break;
        case 3:
          highCount++;
          break;
      }
    }

    lowtxt.setText("" + lowCount);
    medtxt.setText("" + medCount);
    hightxt.setText("" + highCount);

    lowCount = medCount = highCount = 0;

    calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));

    String startDate = sdf.format(calendar.getTime());

    calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));

    String endDate = sdf.format(calendar.getTime());
    events =
        DBConnector.getHelper(getActivity())
            .findEventsBetween(startDate.split(" ")[0], endDate.split(" ")[0], "date", "ascending");

    for (Event e : events) {
      switch (Integer.parseInt(e.getPriority())) {
        case 1:
          lowCount++;
          break;
        case 2:
          medCount++;
          break;
        case 3:
          highCount++;
          break;
      }
    }

    barChart.addBar(
        new BarModel("low priority", lowCount, getResources().getColor(R.color.dark_yellow)));
    barChart.addBar(
        new BarModel("medium priority", medCount, getResources().getColor(R.color.orange)));
    barChart.addBar(new BarModel("high priority", highCount, getResources().getColor(R.color.red)));
  }