Search in sources :

Example 11 with Reddit

use of me.ccrama.redditslide.Reddit in project Slide by ccrama.

the class ForceTouchLink method onCreate.

@Override
public void onCreate(Bundle savedInstance) {
    overridePendingTransition(0, 0);
    super.onCreate(savedInstance);
    applyColorTheme();
    supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_force_touch_content);
    findViewById(android.R.id.content).setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_POINTER_UP) {
                finish();
            }
            return false;
        }
    });
    final String url = getIntent().getExtras().getString("url");
    ContentType.Type t = ContentType.getContentType(url);
    final ImageView mainImage = (ImageView) findViewById(R.id.image);
    MediaVideoView mainVideo = (MediaVideoView) findViewById(R.id.gif);
    mainVideo.setVisibility(View.GONE);
    switch(t) {
        case REDDIT:
            break;
        case IMGUR:
            break;
        case IMAGE:
            ((Reddit) getApplication()).getImageLoader().displayImage(url, mainImage);
            break;
        case GIF:
            mainVideo.setVisibility(View.VISIBLE);
            new GifUtils.AsyncLoadGif(this, mainVideo, null, null, false, true, true, "").execute(url);
            break;
        case ALBUM:
            break;
        case VIDEO:
            break;
        case LINK:
            new AsyncTask<Void, Void, Void>() {

                String urlGotten;

                @Override
                protected Void doInBackground(Void... params) {
                    /*try {
                           urlGotten =  ImageExtractor.extractImageUrl(url);
                        } catch (IOException e) {
                            e.printStackTrace();
                        }*/
                    return null;
                }

                @Override
                protected void onPostExecute(Void aVoid) {
                    ((Reddit) getApplication()).getImageLoader().displayImage(urlGotten, mainImage);
                }
            }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
            break;
    }
}
Also used : ContentType(me.ccrama.redditslide.ContentType) ImageView(android.widget.ImageView) View(android.view.View) MediaVideoView(me.ccrama.redditslide.Views.MediaVideoView) MotionEvent(android.view.MotionEvent) MediaVideoView(me.ccrama.redditslide.Views.MediaVideoView) Reddit(me.ccrama.redditslide.Reddit) GifUtils(me.ccrama.redditslide.util.GifUtils) ImageView(android.widget.ImageView)

Aggregations

Reddit (me.ccrama.redditslide.Reddit)11 View (android.view.View)9 Bitmap (android.graphics.Bitmap)8 FailReason (com.nostra13.universalimageloader.core.assist.FailReason)8 ImageLoadingListener (com.nostra13.universalimageloader.core.listener.ImageLoadingListener)8 ImageView (android.widget.ImageView)6 Handler (android.os.Handler)5 LinearLayout (android.widget.LinearLayout)5 ImageViewAware (com.nostra13.universalimageloader.core.imageaware.ImageViewAware)5 ImageLoadingProgressListener (com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener)5 File (java.io.File)5 IOException (java.io.IOException)5 Submission (net.dean.jraw.models.Submission)5 ProgressBar (android.widget.ProgressBar)4 ContentType (me.ccrama.redditslide.ContentType)4 MediaVideoView (me.ccrama.redditslide.Views.MediaVideoView)4 ValueAnimator (android.animation.ValueAnimator)3 SubmissionsView (me.ccrama.redditslide.Fragments.SubmissionsView)3 SubsamplingScaleImageView (me.ccrama.redditslide.Views.SubsamplingScaleImageView)3 URISyntaxException (java.net.URISyntaxException)2