Android Open Source - FlibityBoop Utils






From Project

Back to project page FlibityBoop.

License

The source code is released under:

Apache License

If you think the Android project FlibityBoop listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * IFT2905 : Interface personne machine// w ww  .  ja  va 2s .  c  o  m
 * Projet de session: FlibityBoop.
 * Team: Vincent CABELI, Henry LIM, Pamela MEHANNA, Emmanuel NOUTAHI, Olivier TASTET
 * @author Emmanuel Noutahi, Vincent Cabeli
 * Cette classe a t modifi pour l'adapter au projet.
 * L'original peut tre trouv ici: https://github.com/thest1/LazyList
 */

package com.maclandrol.flibityboop;

import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.view.View;

public class Utils {
  
  public static String last_query = "";
  
  public static void setLastQuery(String s){
    
    last_query = s;
  }
  
  public static String getLastQuery(){
    
    return last_query;
  }
  
  public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
      byte[] bytes = new byte[buffer_size];
      for (;;) {
        int count = is.read(bytes, 0, buffer_size);
        if (count == -1)
          break;
        os.write(bytes, 0, count);
      }
    } catch (Exception ex) {
    }
  }

  /*
   *  Fusionne deux arraylists de mediainfos dans leur ordre original en les alternant
   */
  public static ArrayList<MediaInfos> entrelace(
      ArrayList<? extends MediaInfos> a, ArrayList<? extends MediaInfos> b) {

    ArrayList<MediaInfos> entrelacee = new ArrayList<MediaInfos>();
    if (a != null && b != null) {
      int max = Math.max(a.size(), b.size());

      for (int i = 0; i < max; i++) {
        if (i < a.size())
          entrelacee.add(a.get(i));
        if (i < b.size())
          entrelacee.add(b.get(i));
      }
    } else {

      try {
        entrelacee.addAll(a);
      } catch (NullPointerException e) {
        e.printStackTrace();
      }

      try {

        entrelacee.addAll(b);
      } catch (NullPointerException e) {
        e.printStackTrace();
      }

    }

    return entrelacee;
  }

  
  //Take a screenshot from activity in order to share it
  //Not used in the App
  public static Bitmap takeScreenShot(Activity activity)
  {
      View act_view = activity.findViewById(android.R.id.content);
      act_view.setDrawingCacheEnabled(true); //enable cache drawing
      act_view.buildDrawingCache();
      Bitmap b1 = act_view.getDrawingCache(); //retrive the cache builded 
      Rect frame = new Rect();
      activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
      int statusBarHeight = frame.top;

      int width=  activity.getWindowManager().getDefaultDisplay().getWidth();
      int height=activity.getWindowManager().getDefaultDisplay().getWidth();

      Bitmap b = Bitmap.createBitmap(b1, 0, statusBarHeight, width, height  - statusBarHeight);
      act_view.destroyDrawingCache();
      return b;
  }
  
  

}




Java Source Code List

com.maclandrol.flibityboop.API.java
com.maclandrol.flibityboop.BaseActivity.java
com.maclandrol.flibityboop.Critics.java
com.maclandrol.flibityboop.DBHelperMedia.java
com.maclandrol.flibityboop.FavoriteActivity.java
com.maclandrol.flibityboop.FileCache.java
com.maclandrol.flibityboop.ImageLoader.java
com.maclandrol.flibityboop.MainActivity.java
com.maclandrol.flibityboop.MediaAdapter.java
com.maclandrol.flibityboop.MediaContentProvider.java
com.maclandrol.flibityboop.MediaDetails.java
com.maclandrol.flibityboop.MediaInfos.java
com.maclandrol.flibityboop.Media.java
com.maclandrol.flibityboop.MemoryCache.java
com.maclandrol.flibityboop.MovieFavoriteCursorAdapter.java
com.maclandrol.flibityboop.MovieListFragment.java
com.maclandrol.flibityboop.RottenTomatoes.java
com.maclandrol.flibityboop.SearchActivity.java
com.maclandrol.flibityboop.SearchSuggestionProvider.java
com.maclandrol.flibityboop.SectionListAdapter.java
com.maclandrol.flibityboop.SettingActivity.java
com.maclandrol.flibityboop.ShowFavoriteCursorAdapter.java
com.maclandrol.flibityboop.TVListFragment.java
com.maclandrol.flibityboop.Tastekid.java
com.maclandrol.flibityboop.TheMovieDB.java
com.maclandrol.flibityboop.TraktTV.java
com.maclandrol.flibityboop.Utils.java