public void onStart() { if (serviceAdapter != null && serviceAdapter.getCount() > 0) { CommonAndroid.showView(false, loading); } else { CommonAndroid.showView(true, loading); } };
public void onSucces(String response) { if (!isFinish()) { CommonAndroid.showView(false, loading); Log.i(TAG, "===> " + response); updateData(); listObject = new ArrayList<ServiceList2Fragment.SeviceListObject>(); try { JSONObject jsonRes = new JSONObject(response); JSONArray jsonArray = jsonRes.getJSONArray("data"); for (int i = 0; i < jsonArray.length(); i++) { SeviceListObject obj = new SeviceListObject(); JSONObject jobj = jsonArray.getJSONObject(i); obj.setId(jobj.getInt("id")); obj.setTitle(jobj.getString("title")); obj.setContent(jobj.getString("content")); obj.setSubTitle(jobj.getString("subtitle")); obj.setExternalUrl(jobj.getString("external_url")); obj.setSlug(jobj.getString("slug")); obj.setType(jobj.getString("type")); obj.setUrl(jobj.getString("url")); obj.setThumbnail(jobj.getString("thumbnail")); listObject.add(obj); } galleryAdapter = new GalleryAdapter(getActivity(), listObject); list.setAdapter(galleryAdapter); String parenTitle = jsonRes.getString("parent_title"); txtTitleHeader.initHeader(parenTitle, parenTitle); } catch (Exception e) { // TODO: handle exception } } };
@Override public View getView(int position, View convertView, ViewGroup parent) { View view = convertView; if (view == null) { view = CommonAndroid.initView(mContext, R.layout.service_list_item_z, null); } ico_indi_gray = (ImageView) view.findViewById(R.id.ico_indi_gray); if (positionSelection == position) { view.setBackgroundResource(R.color.servicelist_first); ico_indi_gray.setImageDrawable(myIcon_select); } else { view.setBackgroundResource(android.R.color.transparent); ico_indi_gray.setImageDrawable(myIcon_unselect); } ImageView img = CommonAndroid.getView(view, R.id.img); TextView text_1 = CommonAndroid.getView(view, R.id.text_1); text_1.setText(listData.get(position).getTitle()); ImageLoaderUtils.getInstance(parent.getContext()) .displayImageHome(listData.get(position).getThumbnail(), img); return view; }
@Override public void bindView(View view, Context context, Cursor c) { if (view == null) { view = CommonAndroid.initView(context, R.layout.service_list_item, null); } if (positionSelection == c.getPosition()) { view.setBackgroundResource(R.color.servicelist_first); // R.color.servicelist_first } else { view.setBackgroundResource(android.R.color.transparent); } ImageView img = CommonAndroid.getView(view, R.id.img); TextView text_1 = CommonAndroid.getView(view, R.id.text_1); TextView text_2 = CommonAndroid.getView(view, R.id.text_2); CommonAndroid.setText(text_1, c, ServiceList.title); CommonAndroid.setText(text_2, c, ServiceList.subtitle); ImageLoaderUtils.getInstance(context) .displayImageHome(CommonAndroid.getString(c, ServiceList.thumbnail), img); }
@Override public View newView(Context arg0, Cursor arg1, ViewGroup arg2) { return CommonAndroid.initView(arg0, R.layout.service_list_item, null); }
@Override public void init(View view) { // initHeader(view, R.id.header, R.string.menu_service_list, // R.string.menu_service_list_j, R.drawable.icon_back, 0); myIcon_select = getResources().getDrawable(R.drawable.ico_indi_gray2); myIcon_unselect = getResources().getDrawable(R.drawable.ico_indi_gray); txtTitleHeader = (HeaderView) view.findViewById(R.id.header); setting = new Setting(getActivity()); txtTitleHeader.initHeader(title, title); ImageButton btnBack = (ImageButton) view.findViewById(R.id.header_btn_left); btnBack.setImageResource(R.drawable.icon_back); btnBack.setOnClickListener(this); ImageButton btnRight = (ImageButton) view.findViewById(R.id.header_btn_right); btnRight.setVisibility(View.INVISIBLE); loading = CommonAndroid.getView(view, R.id.loading); list = CommonAndroid.getView(view, R.id.list); list.setOnItemClickListener(this); flip = CommonAndroid.getView(view, R.id.flip); flip.setOnTouchListener( new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) { SkyMainActivity.sm.setSlidingEnabled(false); SkyMainActivity.sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE); } else if (event.getAction() == MotionEvent.ACTION_CANCEL || event.getAction() == MotionEvent.ACTION_UP) { SkyMainActivity.sm.setSlidingEnabled(true); SkyMainActivity.sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE); } return false; } }); flip.setOnFlipListener( new FlipView.OnFlipListener() { @Override public void onFlippedToPage(FlipView v, int position, long id) { if (galleryAdapter != null) { galleryAdapter.setPositionSelection(position); /*int color = getActivity().getResources().getColor(R.color.color_focus_lion); // list.getChildAt(position).setBackgroundColor(color); for (int i = 0; i < 3; i++) { if (i == position) { list.getChildAt(i).setBackgroundColor(getResources().getColor(R.color.servicelist_first));//color_gray Log.i(TAG, "===> " + position); }else{ list.getChildAt(i).setBackgroundColor(getResources().getColor(android.R.color.transparent)); } }*/ } if (position == 0) { SkyMainActivity.sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); } } }); // updateData(); callApi(); }
public void onError(String message) { if (!isFinish()) { CommonAndroid.showView(false, loading); } };