This repository has been archived by the owner on Aug 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
932 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
247 changes: 247 additions & 0 deletions
247
app/src/main/java/org/ole/learning/planet/planetlearning/Main_Dashboard.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,247 @@ | ||
package org.ole.learning.planet.planetlearning; | ||
|
||
import android.app.ProgressDialog; | ||
import android.graphics.Color; | ||
import android.graphics.drawable.GradientDrawable; | ||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.support.design.widget.FloatingActionButton; | ||
import android.support.design.widget.Snackbar; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.support.design.widget.NavigationView; | ||
import android.support.v4.view.GravityCompat; | ||
import android.support.v4.widget.DrawerLayout; | ||
import android.support.v7.app.ActionBarDrawerToggle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.widget.Button; | ||
import android.widget.LinearLayout; | ||
|
||
import com.couchbase.lite.Database; | ||
import com.couchbase.lite.Document; | ||
import com.couchbase.lite.Manager; | ||
import com.couchbase.lite.Query; | ||
import com.couchbase.lite.QueryEnumerator; | ||
import com.couchbase.lite.QueryRow; | ||
import com.tdscientist.shelfview.BookModel; | ||
import com.tdscientist.shelfview.ShelfView; | ||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.Map; | ||
|
||
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; | ||
|
||
|
||
public class Main_Dashboard extends AppCompatActivity | ||
implements NavigationView.OnNavigationItemSelectedListener { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.main_dashboard); | ||
//Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | ||
//setSupportActionBar(toolbar); | ||
|
||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); | ||
fab.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) | ||
.setAction("Action", null).show(); | ||
} | ||
}); | ||
|
||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); | ||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( | ||
this, drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close); | ||
drawer.addDrawerListener(toggle); | ||
toggle.syncState(); | ||
|
||
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); | ||
navigationView.setNavigationItemSelectedListener(this); | ||
|
||
|
||
} | ||
/* | ||
public void LoadShelfResourceList() { | ||
String memberId = sys_usercouchId; | ||
try { | ||
manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); | ||
Database db = manager.getExistingDatabase("shelf"); | ||
Database resource_Db = manager.getDatabase("resources"); | ||
Query orderedQuery = chViews.ReadShelfByIdView(db).createQuery(); | ||
orderedQuery.setDescending(true); | ||
QueryEnumerator results = orderedQuery.run(); | ||
resourceIdList = new String[results.getCount()]; | ||
resourceTitleList= new String[results.getCount()]; | ||
rsLstCnt = 0; | ||
for (Iterator<QueryRow> it = results; it.hasNext(); ) { | ||
QueryRow row = it.next(); | ||
String docId = (String) row.getValue(); | ||
Document doc = db.getExistingDocument(docId); | ||
Map<String, Object> properties = doc.getProperties(); | ||
Map<String, Object> resource_properties = null; | ||
if(memberId.equals((String) properties.get("memberId"))) { | ||
String myresTitile = ((String) properties.get("resourceTitle")); | ||
String myresId = ((String) properties.get("resourceId")); | ||
String myresType,myresDec,myresExt = ""; | ||
resourceTitleList[rsLstCnt]=myresTitile; | ||
resourceIdList[rsLstCnt]=myresId; | ||
resIDArrayList.add(myresId); | ||
Log.e("tag", "MEMBER ID "+ (String) properties.get("resourceTitle")); | ||
try { | ||
Document resource_doc = resource_Db.getExistingDocument((String) properties.get("resourceId")); | ||
Log.e("tag", "RES ID "+ (String) properties.get("resourceId")); | ||
try { | ||
resource_properties = resource_doc.getProperties(); | ||
}catch(Exception errs){ | ||
Log.e("tag", "OBJECT ERROR "+ errs.toString()); | ||
} | ||
//myresTitile = (String) resource_properties.get("title")+""; | ||
//myresId = (String) properties.get("resourceId")+""; | ||
myresDec = (String) resource_properties.get("author")+""; | ||
myresType = (String) resource_properties.get("averageRating")+""; | ||
myresExt = (String) resource_properties.get("openWith")+""; | ||
rsLstCnt++; | ||
}catch(Exception err){ | ||
Log.e("tag", "ERROR "+ err.getMessage()); | ||
//myresTitile = "Unknown resource .. "; | ||
//myresId = ""; | ||
myresDec = ""; | ||
myresType = ""; | ||
rsLstCnt++; | ||
} | ||
Resource resource = new Resource(); | ||
resource.setTitle(myresTitile); | ||
resource.setThumbnailUrl(getIconType(myresExt)); | ||
resource.setDescription(myresDec); | ||
resource.setRating(myresType); | ||
resource.setGenre(null); | ||
// adding resource to resources array | ||
resourceList.add(resource); | ||
resourceNo++; | ||
} | ||
} | ||
LinearLayout row2 = (LinearLayout) findViewById(R.id.layholder_library); | ||
libraryButtons = new Button[rsLstCnt]; | ||
for( int ButtonCnt=0;ButtonCnt< rsLstCnt;ButtonCnt++) { | ||
libraryButtons[ButtonCnt] = new Button(this); | ||
libraryButtons[ButtonCnt].setText(resourceTitleList[ButtonCnt]); | ||
libraryButtons[ButtonCnt].setId(ButtonCnt); | ||
libraryButtons[ButtonCnt].setBackgroundResource(R.drawable.rounded_corners_black_blue); | ||
libraryButtons[ButtonCnt].setTextColor(getResources().getColor(R.color.white)); | ||
libraryButtons[ButtonCnt].setAllCaps(false); | ||
libraryButtons[ButtonCnt].setPadding(10, 5, 10, 5); | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { | ||
libraryButtons[ButtonCnt].setTextAlignment(View.TEXT_ALIGNMENT_CENTER); | ||
} | ||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(170,MATCH_PARENT); | ||
layoutParams.setMargins(1, 0, 1, 0); // left, top, right, bottom | ||
GradientDrawable drawable = new GradientDrawable(); | ||
drawable.setShape(GradientDrawable.RECTANGLE); | ||
drawable.setStroke(2, Color.WHITE); | ||
drawable.setCornerRadius(2); | ||
drawable.setColor(getResources().getColor(R.color.ole_black_blue)); | ||
libraryButtons[ButtonCnt].setBackgroundDrawable(drawable); | ||
libraryButtons[ButtonCnt].setLayoutParams(layoutParams); | ||
row2.addView(libraryButtons[ButtonCnt]); | ||
try { | ||
manager = new Manager(androidContext, Manager.DEFAULT_OPTIONS); | ||
Document resource_doc = resource_Db.getExistingDocument((String) resourceIdList[ButtonCnt]); | ||
Map<String, Object> resource_properties = resource_doc.getProperties(); | ||
Log.e("tag", "RES ID " + (String) resource_properties.get("resourceId")); | ||
libraryButtons[ButtonCnt].setTextColor(getResources().getColor(R.color.ole_white)); | ||
}catch(Exception errs){ | ||
libraryButtons[ButtonCnt].setTextColor(getResources().getColor(R.color.ole_yellow)); | ||
Log.e("tag", "OBJECT ERROR "+ errs.toString()); | ||
} | ||
libraryButtons[ButtonCnt].setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
if(libraryButtons[view.getId()].getCurrentTextColor()==getResources().getColor(R.color.ole_yellow)){ | ||
MaterialClickDialog(false,resourceTitleList[view.getId()],resourceIdList[view.getId()],view.getId()); | ||
}else{ | ||
mDialog = new ProgressDialog(context); | ||
mDialog.setMessage("Opening please "+resourceTitleList[view.getId()]+" wait..."); | ||
mDialog.setCancelable(true); | ||
mDialog.show(); | ||
openedResourceId=resourceIdList[view.getId()]; | ||
openedResourceTitle = resourceTitleList[view.getId()]; | ||
openedResource =true; | ||
openDoc(resourceIdList[view.getId()]); | ||
Log.e("MyCouch", "Clicked to open "+ resourceIdList[view.getId()]); | ||
} | ||
} | ||
}); | ||
//////////// Save list in Preferences | ||
} | ||
db.close(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
*/ | ||
|
||
@Override | ||
public void onBackPressed() { | ||
DrawerLayout drawer = findViewById(R.id.drawer_layout); | ||
if (drawer.isDrawerOpen(GravityCompat.START)) { | ||
drawer.closeDrawer(GravityCompat.START); | ||
} else { | ||
super.onBackPressed(); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
// Inflate the menu; this adds items to the action bar if it is present. | ||
getMenuInflater().inflate(R.menu.main__dashboard, menu); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
// Handle action bar item clicks here. The action bar will | ||
// automatically handle clicks on the Home/Up button, so long | ||
// as you specify a parent activity in AndroidManifest.xml. | ||
int id = item.getItemId(); | ||
|
||
//noinspection SimplifiableIfStatement | ||
if (id == R.id.action_settings) { | ||
return true; | ||
} | ||
|
||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
@SuppressWarnings("StatementWithEmptyBody") | ||
@Override | ||
public boolean onNavigationItemSelected(MenuItem item) { | ||
// Handle navigation view item clicks here. | ||
int id = item.getItemId(); | ||
|
||
if (id == R.id.nav_camera) { | ||
// Handle the camera action | ||
} else if (id == R.id.nav_gallery) { | ||
|
||
} else if (id == R.id.nav_slideshow) { | ||
|
||
} else if (id == R.id.nav_manage) { | ||
|
||
} | ||
|
||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); | ||
drawer.closeDrawer(GravityCompat.START); | ||
return true; | ||
} | ||
} |
Oops, something went wrong.