Advertisement
angarato_surion

Untitled

May 25th, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.80 KB | None | 0 0
  1.   @Override
  2.     public void onCreate(Bundle savedInstanceState)
  3.     {
  4.       try {
  5.           this.requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
  6.           super.onCreate(savedInstanceState);
  7.  
  8.           setContentView(R.layout.main);
  9.  
  10.           //mToolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
  11.            //setSupportActionBar(mToolbar);
  12.  
  13.          // setSupportActionBar((android.support.v7.widget.Toolbar)mToolbar);
  14.  
  15.            // getSupportActionBar().setDisplayShowHomeEnabled(true);
  16.             ViewConfiguration config = ViewConfiguration.get(this);
  17.             Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
  18.             if(menuKeyField != null) {
  19.                 menuKeyField.setAccessible(true);
  20.                 menuKeyField.setBoolean(config, false);
  21.             }
  22.  
  23.           Constants.SytemLanguage=  Locale.getDefault().getDisplayLanguage();
  24.  
  25.             File f = new File(Environment.getExternalStorageDirectory()+"/BookerDroid");
  26.             Constants.TempPath=f.getAbsolutePath()+"/Temp";
  27.             File f2= new File(Constants.TempPath);
  28.  
  29.             if ( !f.exists())
  30.             {
  31.                 f.mkdir();
  32.             }
  33.             if (!f2.exists())
  34.             {
  35.                 f2.mkdirs()  ;
  36.             }
  37.             BitmapTools.CreateImageStorage();
  38.             if( Constants.SytemLanguage!= Locale.ENGLISH.getDisplayLanguage())
  39.             {
  40.                          
  41.             Constants.cels = Constants.grBookCells;
  42.                 Constants.rtcels=Constants.grLentbookbifCells;
  43.             }
  44.             else
  45.             {
  46.                  Constants.cels = Constants.enBookCells;
  47.                 Constants.rtcels=Constants.enLentbookbifCells;
  48.             }
  49.             prefs= getSharedPreferences(Constants.PREFSFILE, MODE_APPEND);
  50.             Constants.wtusername= prefs.getString(Constants.PREF_WT_USERNAME, null);
  51.             Constants.wtpassword= prefs.getString(Constants.PREF_WT_PASSWORD, null);
  52.             Constants.wtpassphrase=prefs.getString(Constants.PREF_WT_PASSPHRASE, null);
  53.             Constants.wtserverip = prefs.getString(Constants.PREF_WT_SERVERIP, null);
  54.             Constants.wtclientmode= prefs.getBoolean(Constants.PREF_WT_ENABLECLIENTMODE, false);
  55.             Constants.showbasicinfo= prefs.getBoolean(Constants.PREF_SHOWBASICINFO, true);
  56.             Constants.orderby = prefs.getString(Constants.PREF_ORDERBY, Constants.cels[0]);
  57.             Constants.cellsshown=prefs.getStringSet(Constants.PREF_CELLSSHOW, null);
  58.             Constants. customcelsview= prefs.getBoolean(Constants.PREF_CUSTOMlAYOUT, false);
  59.             Constants.downloadBookCovers=prefs.getBoolean(Constants.PREF_BOOKCOVERDOWNLOAD, false);
  60.             Constants.useinternaldatapartition=prefs.getBoolean(Constants.PREF_USEiNTERNALDATA,false);
  61.  
  62.             Constants.dbmng= new BookDatabaseManager(Constants.wtusername,Constants.wtserverip,Constants.wtpassword,
  63.                     Constants.wtpassphrase,this.getApplicationContext(),this);
  64.             Constants.dbmng.CreateDatabse(Constants.cels,false);
  65.             Constants.rtbkmngr  =new LentedBooksDatabaseManager(Constants.wtusername,Constants.wtserverip,
  66.                     Constants.wtpassword,Constants.wtpassphrase,
  67.                     this.getApplicationContext(),this);
  68.             Constants.rtbkmngr.CreateDatabse(Constants.rtcels,false);
  69.             if (Constants.useinternaldatapartition )
  70.             {
  71.               Constants.BookCoverPath= this.getFilesDir().getCanonicalPath();
  72.             }
  73.             else
  74.             {
  75.                 Constants.BookCoverPath=  Environment.getExternalStorageDirectory()+"/BookerDroid/BookCovers";
  76.  
  77.             }
  78.             if ( Constants.downloadBookCovers)
  79.             {
  80.                 new File(Constants.BookCoverPath).mkdirs();
  81.                 new File(Constants.BookCoverPath+"/"+ GoogleBooksConst.thumbsir).mkdirs();
  82.                 new File(Constants.BookCoverPath+"/"+ GoogleBooksConst.fulldir).mkdirs();
  83.             }
  84.             int in=Integer.parseInt(prefs.getString(Constants.PREF_THUMBNAILHEIGHT, "128"));
  85.  
  86.             Constants.thumbnailheight=in ;
  87.             Constants.thumbnailwidth=Integer.parseInt(prefs.getString(Constants.PREF_THUMBNAILWIDTH, "128"));
  88.            Constants.fullsizeheight=Integer.parseInt(prefs.getString(Constants.PREGF_FULLSIZWHEIGHT,"256"));
  89.             Constants.fullsizewidth=Integer.parseInt(prefs.getString(Constants.PREF_FULLSIZEWIDTH, "256"));
  90.          
  91.            
  92.          
  93.          
  94.          
  95.             lstBooks = (ListView)findViewById(R.id.lstBooks);
  96.  
  97.  
  98.             txtTotalBooks=(TextView)this.findViewById(R.id.txtTotalBooks);
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.             lstBooks.setOnItemSelectedListener(new OnItemSelectedListener() {
  106.  
  107.                 @Override
  108.                 public void onItemSelected(AdapterView<?> paLent, View view,
  109.                                            int position, long id) {
  110.                     try {
  111.                         SQLiteCursor cur = (SQLiteCursor)Constants.adapt.getItem(position);
  112.                                 Constants.SelectedCode = cur.getString(0);
  113.                         Log.i(Tools.TAG, Constants.SelectedCode);
  114.  
  115.                     } catch (Exception e) {
  116.                         Base.ErroHandling(e);
  117.                         //   return false;
  118.                     }
  119.  
  120.  
  121.                 }
  122.  
  123.                 @Override
  124.                 public void onNothingSelected(AdapterView<?> paLent) {
  125.  
  126.  
  127.                 }
  128.             });
  129.             lstBooks.setOnItemClickListener(new OnItemClickListener() {
  130.                 @Override
  131.                 public void onItemClick(AdapterView<?> paLent, View view, int position, long id) {
  132.                     try {
  133.                         SQLiteCursor cur = (SQLiteCursor) Constants.adapt.getItem(position);
  134.  
  135.                         if (cur != null) {
  136.                             Constants.SelectedCode = cur.getString(0);
  137.                         }
  138.                         Log.i(Tools.TAG, Constants.SelectedCode);
  139.                       //  if (Constants.showbasicinfo) {
  140.                             Intent tin = new Intent(view.getContext(), BookDetails.class);
  141.  
  142.                             startActivity(tin);
  143.                      //   }
  144.  
  145.  
  146.                     } catch (Exception e) {
  147.  
  148.                         Base.ErroHandling(e);
  149.  
  150.                     }
  151.  
  152.                 }
  153.             });
  154.             lstBooks.setOnItemLongClickListener(new OnItemLongClickListener() {
  155.  
  156.                 @Override
  157.                 public boolean onItemLongClick(AdapterView<?> paLent,
  158.                                                View view, int position, long id) {
  159.                     try {
  160.                         SQLiteCursor cur = (SQLiteCursor) Constants.adapt.getItem(position);
  161.  
  162.                         if (cur != null) {
  163.                             Constants.SelectedCode = cur.getString(0);
  164.                         }
  165.                         Log.i(Tools.TAG, Constants.SelectedCode);
  166.                         if (Constants.showbasicinfo) {
  167.                             Intent tin = new Intent(view.getContext(), BookDetails.class);
  168.  
  169.                             startActivity(tin);
  170.                         }
  171.  
  172.                         return true;
  173.                     } catch (Exception e) {
  174.  
  175.                         Base.ErroHandling(e);
  176.                         return false;
  177.                     }
  178.  
  179.                 }
  180.             });
  181.  
  182.             this.txtMoreinfo= (TextView) findViewById(R.id.detailinfo);
  183.             if( Constants.showbasicinfo)
  184.             {
  185.                 this.txtMoreinfo.setVisibility(View.VISIBLE);
  186.             }
  187.             else
  188.             {
  189.                 this.txtMoreinfo.setHeight(0);
  190.                 this.txtMoreinfo.setWidth(0);
  191.             }
  192.  
  193.        
  194.         //  Constants.cels = grBookCells;
  195.            LoadTable(this);
  196.  
  197.  
  198.         }
  199.        catch (Exception ex)
  200.         {
  201.             //throw (ex);
  202.           Base.ErroHandling(ex);
  203.         }
  204.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement