FrescoImageViewer
FrescoImageViewer copied to clipboard
rotate the image
hello i have a question.is it possible to rotate image with Touch or button? because my activity seated to portrait orientation and i don't want my activity rotated automatically and i want just image rotating by click on button or Touch. (sorry for my english)
Hello @arta666 Did you find solution for that?
Hi, In case you were still wondering, I faced the same issue and I fixed in a smart way I guess.
First I removed the block of showing the gallery from activity I was using, and created another empty activity(No problem if creating no layout for it), this activity had two methods only, the onCreate callback which will have the ImageViewer call, and a static method called startActivity that I would pass the start position, the context of the calling activity (The one that had the ImageViewer previously) and the ArrayList containing the images.
I would set the data, and call context.startActivity to start the activity, once it launches it shows the FrescoImageViewer automatically, as we registered the call in the onCreate.
I also added a setOnDismissListener so I could call finish the activity if the gallery was dismissed.
Here is the code for doing the trick:
class CarDetailsGalleryActivity: AppCompatActivity() {
companion object {
private lateinit var mListOfCarImages: ArrayList<String>
private var mPosition: Int = 0
fun startActivity(context: Context, listOfCarImages: ArrayList<String>, position: Int) {
var intent = Intent(context, CarDetailsGalleryActivity::class.java)
mListOfCarImages = listOfCarImages
mPosition = position
context.startActivity(intent)
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
ImageViewer.Builder(this, mListOfCarImages)
.setStartPosition(mPosition)
.setOnDismissListener { finish() }
.setOverlayView(cl_car_details_gallery)
.show()
}
}
Here is how I called it:
CarDetailsGalleryActivity.startActivity(this, mListOfCarImages, position)
Yea, in case you were wondering, this is KOTLIN babeee <3
I am just like @arta666 was, trying to rotate the image detail view of the ImageViewer class using the phone sensor, as my app is using portrait mode but I want the images to be able to be visualized in landscape mode too.
Following @OmarKRostom 's I have managed to get something, but not the whole solution.
I am getting a blank activity and beneath it the loading of the detail of the gallery.
public class DetailImageActivity extends AppCompatActivity {
static String [] mList ;
private static int mPosition = 0;
static Context mContext;
public DetailImageActivity() {
}
public DetailImageActivity(Context context, String[] singleList, int position) {
this.mList = singleList;
this.mPosition = position;
this.mContext = context;
}
public static void startActivity(Context context, String[] singleList, int position)
{
Intent intent = new Intent(context, DetailImageActivity.class);
mList = singleList;
mPosition = position;
mContext = context;
context.startActivity(intent);
}
@Override
protected void onCreate(Bundle savedInstanceState ) {
super.onCreate(savedInstanceState);
new ImageViewer.Builder(mContext, mList)
.setStartPosition(mPosition)
.setOnDismissListener(new ImageViewer.OnDismissListener() {
@Override
public void onDismiss() {
finish();
}
})
.show();
}
}
So right now I am calling the class like this :
DetailImageActivity.startActivity(context, singleList, position);
but I am getting this : Screenshot
And after clossing that activity, the correct ImageView appears (it was beneath that blank activity). Do you know what the issue might be here?
it would be great if @OmarKRostom could share the cl_car_details_gallery file.
Cheers!
J.