R
Rackor
Neues Mitglied
- 0
Hallo, wie der Titel schon sagt, habe ich das Problem, dass ich es nicht hinbekomme, in meinem Fragment die ImageViews upzudaten...
folgender Aufbau...
ich habe eine Activity mit einem Foto welches von einer DB geladen wird..bei klick auf das Foto start die FragmentActivity mit den Fragments..dabei wird das Foto sogleich übergeben und sofort angezeigt..weiters gibt es standardgemäß noch ein weiteres Fragment für das hinzufügen von Fotos.
bei onClick öffnet sich die Gallery des Gerätes und ein Foto auswählen zu können..danach soll es noch decodiert/in der Größe angepasst werden und in die ImageView geladen werden...bzw sollte am besten ein neues Fragment mit einer ImageView und dem geladenen Foto erzeugt und an vorletzte Stelle des Viewpagers eingeschoben werden...das laden etc. funktioniert soweit..jedoch weiß ich nicht, wie ich nun die Fragmente updaten kann, bzw dynamisch neue erstellen/hinzufügen/anzeigen kann.
Bitte um Hilfe!
Hier mein Code:
folgender Aufbau...
ich habe eine Activity mit einem Foto welches von einer DB geladen wird..bei klick auf das Foto start die FragmentActivity mit den Fragments..dabei wird das Foto sogleich übergeben und sofort angezeigt..weiters gibt es standardgemäß noch ein weiteres Fragment für das hinzufügen von Fotos.
bei onClick öffnet sich die Gallery des Gerätes und ein Foto auswählen zu können..danach soll es noch decodiert/in der Größe angepasst werden und in die ImageView geladen werden...bzw sollte am besten ein neues Fragment mit einer ImageView und dem geladenen Foto erzeugt und an vorletzte Stelle des Viewpagers eingeschoben werden...das laden etc. funktioniert soweit..jedoch weiß ich nicht, wie ich nun die Fragmente updaten kann, bzw dynamisch neue erstellen/hinzufügen/anzeigen kann.
Bitte um Hilfe!
Hier mein Code:
Code:
public[SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ScreenSlidePageFragment [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]extends[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Fragment{
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]static[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]RESULT_LOAD_IMAGE[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 2;
ArrayList<String> [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]test[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ArrayList<String>();
Bitmap [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]profilePic[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
ImageView [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]imgView[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
UserProfilePub_viewpager [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]actRef[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
Bitmap [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]bitmap[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]pos[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
ArrayList<Bitmap> [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]bitmaps[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ArrayList<Bitmap>();
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ScreenSlidePageFragment newInstance(Bitmap profilePic, ArrayList<Bitmap> bitmaps, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] pos){
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]bitmaps[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = bitmaps;
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]profilePic[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = profilePic;
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]pos[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = pos;
ScreenSlidePageFragment f = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ScreenSlidePageFragment();
Bundle bdl = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Bundle();
bdl.putParcelableArrayList([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"profilePics"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], bitmaps);
bdl.putInt([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"pos"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], pos);
bdl.putParcelable([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"profilePic"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], profilePic);
f.setArguments(bdl);
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] f;
}
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle saveInstanceState){
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]fragment_screen_slide_page[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], container, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]false[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]imgView[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = (ImageView) rootView.findViewById(R.id.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]up_pub_iv_viewpager[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](getArguments().getInt([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"pos"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) == 0){
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]imgView[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setImageBitmap((Bitmap) getArguments().getParcelable([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"profilePic"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]));
}[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]{
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [U]position[/U] = getArguments().getInt([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"pos"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]bitmaps[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = getArguments().getParcelableArrayList([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"profilePics"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]if(bitmaps.get(position-1) != null){[/SIZE]
[SIZE=2]imgView.setImageBitmap(Bitmaps.get(position-1);[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]imgView[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setOnLongClickListener([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] OnLongClickListener(){
[/SIZE][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]boolean[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] onLongClick(View arg0) {
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]loadPic([/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]imgView[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]false[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
}
});
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]}
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] rootView;
}
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] onActivityCreated(Bundle savedInstanceState){
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]super[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].onActivityCreated(savedInstanceState);
}
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] loadPic(ImageView imgView){
Intent intent = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Intent(Intent.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]ACTION_PICK[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], android.provider.MediaStore.Images.Media.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]EXTERNAL_CONTENT_URI[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] vID = imgView.getId();
intent.putExtra([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"vID"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], vID);
startActivityForResult(intent, [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]RESULT_LOAD_IMAGE[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE][SIZE=2]
}[/SIZE][SIZE=2]
}
[/SIZE][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]//////////////////////////////////////
FragmentActivity mit inner Class für Custom Adapter:
[/SIZE][/FONT][/SIZE][/FONT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] UserProfilePub_viewpager [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]extends[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FragmentActivity {
ArrayList<Bitmap> [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]pics[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ArrayList<Bitmap>();
UserProfilePub_viewpager [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]actRef[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
String [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]url[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=[/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"****************************************"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
Bitmap [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]profilePic[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]pos[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]static[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]NUM_PAGES[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 2;
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ViewPager [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mPager[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PagerAdapter [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mPagerAdapter[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
ImageView [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]imgView[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]protected[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] onCreate(Bundle savedInstanceState) {
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]super[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].onCreate(savedInstanceState);
setContentView(R.layout.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]viewpager_layout_activity[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
Intent intent = getIntent();
String USID = intent.getExtras().getString([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"USID"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]profilePic[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = intent.getExtras().getParcelable([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"profilePic"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
[/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]pics[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = intent.getParcelableArrayListExtra([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"profilePics"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
ArrayList<NameValuePair> nameValuePair = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ArrayList<NameValuePair>();
nameValuePair.add([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BasicNameValuePair([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"USID"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], USID));
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mPager[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = (ViewPager) findViewById(R.id.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]pager[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mPagerAdapter[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ScreenSlidePagerAdapter(getSupportFragmentManager(), [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]profilePic[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]pics[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mPager[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setAdapter([/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mPagerAdapter[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
}
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] onBackPressed(){
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mPager[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].getCurrentItem() == 0){
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]super[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].onBackPressed();
}[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]{
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mPager[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setCurrentItem([/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mPager[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].getCurrentItem() - 1);
}
}
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]static[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ScreenSlidePagerAdapter [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]extends[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FragmentStatePagerAdapter{
ArrayList<Bitmap> [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]pics[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ArrayList<Bitmap>();
Bitmap [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]profilePic[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ScreenSlidePagerAdapter(FragmentManager fm, Bitmap profilePic, ArrayList<Bitmap> pics) {
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]super[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](fm);
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]pics[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = pics;
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]profilePic[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = profilePic;
}
[/SIZE][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Fragment getItem([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] pos){
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ScreenSlidePageFragment().newInstance([/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]profilePic[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]pics[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], pos);
}
[/SIZE][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] getCount() {
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// [/COLOR][/SIZE][/COLOR][/SIZE][B][SIZE=2][COLOR=#7f9fbf][SIZE=2][COLOR=#7f9fbf]TODO[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f] Auto-generated method stub
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]NUM_PAGES[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
}
}
[/SIZE][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]boolean[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] onCreateOptionsMenu(Menu menu) {
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Inflate the menu; this adds items to the action bar if it is present.
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]getMenuInflater().inflate(R.menu.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]user_profile_pub_viewpager[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], menu);
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]true[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
}
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]protected[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] onActivityResult([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] requestCode, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] resultCode, Intent data){
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]super[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].onActivityResult(requestCode, resultCode, data);
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] RESULT_LOAD_IMAGE = 2;
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](requestCode == RESULT_LOAD_IMAGE && resultCode == [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]RESULT_OK[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] && [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] != data){
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] vID = data.getExtras().getInt([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"vID"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]imgView[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = (ImageView) findViewById(vID);
Uri selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]DATA[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]};
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
cursor.moveToFirst();
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
Cursor.close();[/SIZE][SIZE=2]
decodeBitmap decBit = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] decodeBitmap(picturePath, [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]imgView[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
decBit.execute();[/SIZE][SIZE=2]
}
}
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] savePic(Bitmap bitmap){
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]pics[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].add(bitmap);
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]
// Hier sollte dann der Update der Fragmente stattfinden[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]
}
}
[/SIZE][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]////////////////////////////////
AsyncTask zum decodieren der Fotos:
[/SIZE][/FONT][/SIZE][/FONT]
[SIZE=2]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] decodeBitmap [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]extends[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] AsyncTask<String, Integer, Bitmap> {
BitmapFactory.Options [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]options[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BitmapFactory.Options();
Bitmap [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]profilePic[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]static[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]byte[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][] [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]bytes[/I][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
String [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]picturePath[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
ImageView [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]InputImage[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] decodeBitmap(String picturePath, ImageView InputImage){
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]picturePath[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = picturePath;
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]InputImage[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = InputImage;
}
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] calculateInSampleSize(BitmapFactory.Options options, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] reqWidth, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] reqHeight) {
options.[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]inJustDecodeBounds[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]true[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
BitmapFactory.[I]decodeFile[/I]([/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]picturePath[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], options);
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [U]imageHeight[/U] = options.[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]outHeight[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [U]imageWidth[/U] = options.[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]outWidth[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
String [U]imageType[/U] = options.[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]outMimeType[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Raw height and width of image
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] height = options.[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]outHeight[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] width = options.[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]outWidth[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] inSampleSize = 1;
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (height > reqHeight || width > reqWidth) {
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Calculate ratios of height and width to requested height and width
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] heightRatio = Math.[I]round[/I](([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]float[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) height / ([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]float[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) reqHeight);
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] widthRatio = Math.[I]round[/I](([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]float[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) width / ([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]float[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) reqWidth);
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Choose the smallest ratio as inSampleSize value, this will guarantee
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// a final image with both dimensions larger than or equal to the
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// requested height and width.
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
}
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] inSampleSize;
}
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Bitmap decodeSampledBitmapFromFile(String picturePath, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] reqWidth, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] reqHeight) {
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// First decode with inJustDecodeBounds=true to check dimensions
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BitmapFactory.Options options = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BitmapFactory.Options();
options.[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]inJustDecodeBounds[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]true[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
BitmapFactory.[I]decodeFile[/I](picturePath, options);
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Calculate inSampleSize
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]options.[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]inSampleSize[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = calculateInSampleSize(options, reqWidth, reqHeight);
[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Decode bitmap with inSampleSize set
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]options.[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]inJustDecodeBounds[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]false[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BitmapFactory.[I]decodeFile[/I](picturePath, options);
}
[/SIZE][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]protected[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Bitmap doInBackground(String... params) {
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] decodeSampledBitmapFromFile([/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]picturePath[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 200, 200);
}
[/SIZE][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]protected[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] onPostExecute(Bitmap bitmap) {
[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]if(InputImage != null){ [/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0] InputImage[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setImageBitmap(bitmap);[/SIZE]
[SIZE=2]}
UserProfilePub_viewpager test = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [U]UserProfilePub_viewpager[/U]();
test.savePic(bitmap);
}
}
[/SIZE][FONT=Calibri][SIZE=3][FONT=Calibri][SIZE=3]
[/SIZE][/FONT][/SIZE][/FONT]