@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.view_pager, container, false); // Set the pager with an adapter ViewPager pager = (ViewPager) view.findViewById(R.id.pager); pager.setAdapter( new VideoPagerAdapter( getFragmentManager(), type, itemId, name, getActivity().getApplicationContext())); // Bind the widget to the adapter tabs = (PagerSlidingTabStrip) view.findViewById(R.id.tabs); tabs.setViewPager(pager); colorView = new ColorView(tabs, getActivity().getApplicationContext()); colorView.changeColorTabs(user.getColor()); return view; }
@Override protected String doInBackground(String... params) { try { // Use BasicNameValuePair to create GET data List<NameValuePair> pairs = new ArrayList<NameValuePair>(); pairs.add(new BasicNameValuePair("token", user.getTokenkey())); pairs.add(new BasicNameValuePair("method", "accountapi.getPhotoAlbums")); if (params[0] != null) { if (user_id != null) { pairs.add(new BasicNameValuePair("user_id", "" + params[0])); } else if (page_id != null) { pairs.add(new BasicNameValuePair("module", "pages")); pairs.add(new BasicNameValuePair("item_id", "" + params[0])); } } pairs.add(new BasicNameValuePair("limit", "2")); pairs.add(new BasicNameValuePair("page", "0")); // url request String URL = null; if (Config.CORE_URL == null) { URL = Config.makeUrl(user.getCoreUrl(), null, false); } else { URL = Config.makeUrl(Config.CORE_URL, null, false); } // request GET method to server resultstring = networkUntil.makeHttpRequest(URL, "GET", pairs); JSONObject mainJSON = new JSONObject(resultstring); JSONArray outJson = mainJSON.getJSONArray("output"); arrayOfList = new ArrayList<Album>(); for (int i = 0; i < outJson.length(); i++) { JSONObject JsonAlbum = outJson.getJSONObject(i); Album album = new Album(); album.setAlbum_id(JsonAlbum.getString("album_id")); album.setUser_id(JsonAlbum.getString("user_id")); album.setName(JsonAlbum.getString("name")); album.setDescription(JsonAlbum.getString("description")); album.setTime_phrase(JsonAlbum.getString("time_phrase")); album.setAlbum_total(JsonAlbum.getString("total_photo")); album.setAlbum_pic(JsonAlbum.getJSONObject("photo_sizes").getString("100")); arrayOfList.add(album); } } catch (Exception ex) { // Log.i("comment item", ex.getMessage()); } return resultstring; }
@Override protected String doInBackground(String... params) { try { // Use BasicNameValuePair to create GET data List<NameValuePair> pairs = new ArrayList<NameValuePair>(); pairs.add(new BasicNameValuePair("token", user.getTokenkey())); pairs.add(new BasicNameValuePair("method", "accountapi.getPhotos")); if (page > 1) { pairs.add(new BasicNameValuePair("page", "" + page)); } else { pairs.add(new BasicNameValuePair("page", "undefined")); } if (params[0] != null) { if (user_id != null) { pairs.add(new BasicNameValuePair("user_id", "" + params[0])); } else if (page_id != null) { pairs.add(new BasicNameValuePair("module", "pages")); pairs.add(new BasicNameValuePair("item_id", "" + params[0])); } else if (module_id != null) { pairs.add(new BasicNameValuePair("module", "pages")); pairs.add(new BasicNameValuePair("item_id", "" + params[0])); } if (params[1] != null) { pairs.add(new BasicNameValuePair("album_id", "" + params[1])); } } // url request String URL = null; if (Config.CORE_URL == null) { URL = Config.makeUrl(user.getCoreUrl(), null, false); } else { URL = Config.makeUrl(Config.CORE_URL, null, false); } // request GET method to server resultstring = networkUntil.makeHttpRequest(URL, "GET", pairs); JSONObject mainJSON = new JSONObject(resultstring); JSONArray outJson = mainJSON.getJSONArray("output"); if (stringArrayList == null) { stringArrayList = new ArrayList<String>(); PagerList = new ArrayList<String>(); ImagesId = new ArrayList<String>(); HasLike = new ArrayList<String>(); FeedisLike = new ArrayList<String>(); Total_like = new ArrayList<String>(); Total_comment = new ArrayList<String>(); Itemid = new ArrayList<String>(); Type = new ArrayList<String>(); } if (outJson.length() < 20) { viewmore = 1; } else { float leng = outJson.length(); float itemv = itemView; countImage = leng / itemv; } System.out.println(outJson.length()); System.out.println(countImage); for (int i = 0; i < outJson.length(); i++) { JSONObject JsonPic = outJson.getJSONObject(i); stringArrayList.add(JsonPic.getJSONObject("photo_sizes").getString("100")); ImagesId.add(JsonPic.getString("photo_id")); if (JsonPic.has("feed_total_like")) { HasLike.add(JsonPic.getString("feed_total_like")); Total_like.add(JsonPic.getString("feed_total_like")); } if (JsonPic.has("item_id")) { Itemid.add(JsonPic.getString("item_id")); } if (!JsonPic.isNull("feed_is_liked") && JsonPic.getString("feed_is_liked") != "false") { if (!"".equals(JsonPic.getString("feed_is_liked"))) { FeedisLike.add("feed_is_liked"); } else { FeedisLike.add("null"); } } if (JsonPic.has("total_comment")) { Total_comment.add(JsonPic.getString("total_comment")); } Type.add(JsonPic.getJSONObject("social_app").getString("type_id")); if (Build.VERSION.SDK_INT == Build.VERSION_CODES.GINGERBREAD) { PagerList.add(JsonPic.getJSONObject("photo_sizes").getString("240")); } else { PagerList.add(JsonPic.getJSONObject("photo_sizes").getString("500")); } } imagePhotoIds = ImagesId.toArray(new String[ImagesId.size()]); imageUrls = stringArrayList.toArray(new String[stringArrayList.size()]); imageCount = stringArrayList.size(); imagePager = PagerList.toArray(new String[stringArrayList.size()]); imageHasLike = HasLike.toArray(new String[HasLike.size()]); imageFeedisLike = FeedisLike.toArray(new String[FeedisLike.size()]); imageTotal_like = Total_like.toArray(new String[Total_like.size()]); imageTotal_comment = Total_comment.toArray(new String[Total_comment.size()]); imageItemid = Itemid.toArray(new String[Itemid.size()]); imageType = Type.toArray(new String[Type.size()]); imageType = Type.toArray(new String[Type.size()]); } catch (Exception ex) { } return resultstring; }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // create view from friend_fragment xml View view = inflater.inflate(R.layout.info_fragment, container, false); scrollViewLayout = (ScrollView) view.findViewById(R.id.scrollview_user_info); profile_image = (ImageView) view.findViewById(R.id.profile_image); profile_fullname = (TextView) view.findViewById(R.id.profile_fullname); profile_location = (TextView) view.findViewById(R.id.profile_location); profile_birthday = (TextView) view.findViewById(R.id.profile_birthday); profile_cover = (ImageView) view.findViewById(R.id.item_img_cover); info_gender = (TextView) view.findViewById(R.id.profile_info_text_gender); info_age = (TextView) view.findViewById(R.id.profile_info_text_age); info_location = (TextView) view.findViewById(R.id.profile_info_text_location); info_sexuality = (TextView) view.findViewById(R.id.profile_info_text_sexuality); info_relation = (TextView) view.findViewById(R.id.profile_info_text_relation); info_last_login = (TextView) view.findViewById(R.id.profile_info_text_last_login); info_member_since = (TextView) view.findViewById(R.id.profile_info_text_member_since); info_membership = (TextView) view.findViewById(R.id.profile_info_text_membership); info_profile_view = (TextView) view.findViewById(R.id.profile_info_text_Profile_Views); info_rss_subscribers = (TextView) view.findViewById(R.id.profile_info_text_RSS_Subscribers); actionFriend = (Button) view.findViewById(R.id.profile_actionFriend); MessageBtn = (Button) view.findViewById(R.id.profile_MessageBtn); info_profile = (TextView) view.findViewById(R.id.profile_info); info_profile.setText( phraseManager.getPhrase(getActivity().getApplicationContext(), "profile.basic_info")); statusTxt = (TextView) view.findViewById(R.id.statusTxt); statusTxt.setText( phraseManager.getPhrase(getActivity().getApplicationContext(), "feed.status")); checkInTxt = (TextView) view.findViewById(R.id.checkinTxt); checkInTxt.setText( phraseManager.getPhrase(getActivity().getApplicationContext(), "accountapi.check_in")); photoTxt = (TextView) view.findViewById(R.id.photoTxt); photoTxt.setText(phraseManager.getPhrase(getActivity().getApplicationContext(), "user.photo")); shareImage = (ImageView) view.findViewById(R.id.image_icon_status); photoImage = (ImageView) view.findViewById(R.id.image_icon_photo); share_button = (RelativeLayout) view.findViewById(R.id.share_button); photo_button = (RelativeLayout) view.findViewById(R.id.photo_button); checkInButton = (RelativeLayout) view.findViewById(R.id.checkin_button); /*............custom profile.....profile_aboutme,profile_whomeet,profile_movies,profile_interests,profile_music*/ profile_aboutme = (TextView) view.findViewById(R.id.pages_info_aboutme); profile_aboutme.setText(aboutme); profile_whomeet = (TextView) view.findViewById(R.id.pages_info_whomeet); profile_whomeet.setText(whomeet); profile_movies = (TextView) view.findViewById(R.id.pages_info_movies); profile_movies.setText(movies); profile_interests = (TextView) view.findViewById(R.id.pages_info_interests); profile_interests.setText(interests); /* user.getCheckin(); Boolean.parseBoolean(user.getCheckin()); user.getUserId(); sUserId.equals(user.getUserId()); */ if (sPagesId == null && Boolean.parseBoolean(user.getCheckin()) && sUserId != null && user != null && user.getUserId() != null && sUserId.equals(user.getUserId())) { checkInButton.setVisibility(View.VISIBLE); } else { checkInButton.setVisibility(View.GONE); } share_button.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { statusTxt.setTextColor(Color.parseColor("#ffffff")); changeColorAction(share_button, user.getColor()); shareImage.setImageResource(R.drawable.status_white_icon); Intent intent = new Intent(getActivity(), ImageUpload.class); if (sUserId != null || sPagesId != null) { if (sPagesId != null) { intent.putExtra("page_id", sPagesId); intent.putExtra("owner_user_id", objProfileInfo.getUser_id()); intent.putExtra("page_title", objProfileInfo.getTitle()); intent.putExtra("fullname", objProfileInfo.getFullname()); intent.putExtra("profile_page_id", objProfileInfo.getProfile_page_id()); intent.putExtra("pages_image", objProfileInfo.getPagesImage()); } else { intent.putExtra("user_id", objProfileInfo.getUser_id()); } } else { intent.putExtra("owner_user_id", user.getUserId()); } getActivity().startActivity(intent); } }); photo_button.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { photoTxt.setTextColor(Color.parseColor("#ffffff")); changeColorAction(photo_button, user.getColor()); photoImage.setImageResource(R.drawable.photo_white_icon); Intent intent = new Intent(getActivity(), AlbumSelectedActivity.class); if (sUserId != null || sPagesId != null) { if (sPagesId != null) { intent.putExtra("page_id", sPagesId); intent.putExtra("owner_user_id", objProfileInfo.getUser_id()); intent.putExtra("page_title", objProfileInfo.getTitle()); intent.putExtra("fullname", objProfileInfo.getFullname()); intent.putExtra("profile_page_id", objProfileInfo.getProfile_page_id()); intent.putExtra("pages_image", objProfileInfo.getPagesImage()); } else { intent.putExtra("user_id", objProfileInfo.getUser_id()); } } else { intent.putExtra("owner_user_id", user.getUserId()); } getActivity().startActivity(intent); } }); checkInButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { checkInButton.setBackgroundColor(Color.parseColor("#f3f3f3")); Intent intent = new Intent(getActivity(), CheckInActivity.class); startActivity(intent); } }); // set gender phrase TextView genderTxt = (TextView) view.findViewById(R.id.gender_txt); genderTxt.setText( phraseManager.getPhrase(getActivity().getApplicationContext(), "profile.gender")); // set age phrase TextView ageTxt = (TextView) view.findViewById(R.id.age_txt); ageTxt.setText(phraseManager.getPhrase(getActivity().getApplicationContext(), "profile.age")); // set location phrase TextView localtionTxt = (TextView) view.findViewById(R.id.location_txt); localtionTxt.setText( phraseManager.getPhrase(getActivity().getApplicationContext(), "profile.location")); // set sexuality phrase TextView sexualityTxt = (TextView) view.findViewById(R.id.sexuality_txt); sexualityTxt.setText("Sexuality"); // set relation phrase TextView relationTxt = (TextView) view.findViewById(R.id.relation_txt); relationTxt.setText("Relationship Status"); // set last login phrase TextView lastLoginTxt = (TextView) view.findViewById(R.id.last_login_txt); lastLoginTxt.setText( phraseManager.getPhrase(getActivity().getApplicationContext(), "profile.last_login")); // set member since phrase TextView membersinceTxt = (TextView) view.findViewById(R.id.member_since_txt); membersinceTxt.setText( phraseManager.getPhrase(getActivity().getApplicationContext(), "profile.member_since")); // set membership phrase TextView membershipTxt = (TextView) view.findViewById(R.id.membership_txt); membershipTxt.setText( phraseManager.getPhrase(getActivity().getApplicationContext(), "profile.membership")); // set view profile phrase TextView viewProfileTxt = (TextView) view.findViewById(R.id.view_profile_txt); viewProfileTxt.setText( phraseManager.getPhrase(getActivity().getApplicationContext(), "user.view_profile")); // set rss phrase TextView rssTxt = (TextView) view.findViewById(R.id.rss_subscribers_txt); rssTxt.setText( phraseManager.getPhrase(getActivity().getApplicationContext(), "profile.rss_subscribers")); profile_info = (RelativeLayout) view.findViewById(R.id.profile_info_arena); pages_info = (TextView) view.findViewById(R.id.pages_info); // no internet connection noInternetLayout = (RelativeLayout) view.findViewById(R.id.no_internet_layout); noInternetBtn = (Button) view.findViewById(R.id.no_internet_button); noInternetTitle = (TextView) view.findViewById(R.id.no_internet_title); noInternetContent = (TextView) view.findViewById(R.id.no_internet_content); noInternetImg = (ImageView) view.findViewById(R.id.no_internet_image); noInternetLayoutInfo = (RelativeLayout) view.findViewById(R.id.no_internet_info_layout); // change color for no internet colorView.changeImageForNoInternet(noInternetImg, noInternetBtn, user.getColor()); // set text for no internet element noInternetBtn.setText( phraseManager.getPhrase(getActivity().getApplicationContext(), "accountapi.try_again")); noInternetTitle.setText( phraseManager.getPhrase( getActivity().getApplicationContext(), "accountapi.no_internet_title")); noInternetContent.setText( phraseManager.getPhrase( getActivity().getApplicationContext(), "accountapi.no_internet_content")); // action click load try again noInternetBtn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View arg0) { final Handler handler = new Handler(); handler.postDelayed( new Runnable() { @Override public void run() { // fetch data loadUserInfo(); } }, 2000); } }); return view; }