Skip to content

Commit

Permalink
Updated layout with sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
HiiYL committed Apr 23, 2015
1 parent 725ca06 commit 8ae9a22
Show file tree
Hide file tree
Showing 28 changed files with 1,264 additions and 900 deletions.
11 changes: 11 additions & 0 deletions .idea/libraries/netroid_1_2_1.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

669 changes: 314 additions & 355 deletions .idea/workspace.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<orderEntry type="library" exported="" name="support-v4-22.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.0.0" level="project" />
<orderEntry type="library" exported="" name="play-services-gcm-7.0.0" level="project" />
<orderEntry type="library" exported="" name="netroid-1.2.1" level="project" />
<orderEntry type="library" exported="" name="volley" level="project" />
<orderEntry type="library" exported="" name="library-2.4.0" level="project" />
<orderEntry type="library" exported="" name="MaterialDesign-1.4" level="project" />
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ dependencies {
compile 'com.google.android.gms:play-services-gcm:7.0.0'
compile 'com.github.navasmdc:MaterialDesign:1.+@aar'
compile 'com.nineoldandroids:library:2.4.+'
compile 'com.duowan.android.netroid:netroid:1.2.1'
// // Support Libraries
// compile 'com.android.support:appcompat-v7:21.0.3'
// compile 'com.android.support:cardview-v7:21.0.3'
Expand Down
Binary file modified app/src/main/.DS_Store
Binary file not shown.
35 changes: 19 additions & 16 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen" >
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
Expand All @@ -25,20 +25,14 @@
</activity>
<activity
android:name=".LoginActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"
android:excludeFromRecents="true"
android:label="@string/title_activity_login"
android:noHistory="true" >
</activity>
<activity
android:name=".MMLS"
android:label="@string/title_activity_mmls"
android:parentActivityName=".MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.github.hiiyl.mmuhub.MainActivity" />
</activity>
<activity
android:name=".MMLSActivity"

android:label="@string/title_activity_mmls" >
</activity>
<activity
Expand All @@ -60,31 +54,40 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="com.github.hiiyl.mmuhub.MMLSActivity" />
</activity>

<provider
android:authorities="com.github.hiiyl.mmuhub"
android:name=".data.MMUProvider"
android:authorities="com.github.hiiyl.mmuhub"
android:enabled="true"
android:exported="false"
android:syncable="true"
android:permission="com.myapp.LICENSE_TO_KILL"/>
android:permission="com.myapp.LICENSE_TO_KILL"
android:syncable="true" />

<service
android:name=".sync.MMUSyncService"
android:exported="true"
>
android:exported="true" >
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>

<meta-data
android:name="android.content.SyncAdapter"
android:resource="@xml/syncadapter" />
</service>
<service android:name=".sync.MMUAuthenticatorService">
<service android:name=".sync.MMUAuthenticatorService" >
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data android:name="android.accounts.AccountAuthenticator"

<meta-data
android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>

<activity
android:name=".BaseActivity"
android:label="@string/title_activity_base" >
</activity>
</application>

</manifest>
164 changes: 164 additions & 0 deletions app/src/main/java/com/github/hiiyl/mmuhub/BaseActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
package com.github.hiiyl.mmuhub;

import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBarDrawerToggle;
import android.util.Log;
import android.view.Gravity;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.github.hiiyl.mmuhub.data.MMUDbHelper;

import java.util.Map;


public class BaseActivity extends ActionBarActivity
{
private static final long NAVDRAWER_LAUNCH_DELAY = 250;
public DrawerLayout mDrawerLayout;
public ListView mDrawerList;
public String[] layers;
private ActionBarDrawerToggle mDrawerToggle;
private ArrayAdapter<String> mArrayAdapter;
private Map map;
private String mActivityTitle;
private Handler mHandler;
private Runnable mPendingRunnable;

protected void onCreateDrawer()
{
// R.id.drawer_layout should be in every activity with exactly the same id.
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

mHandler = new Handler();

mActivityTitle = getTitle().toString();

mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.string.drawer_open, R.string.drawer_close) {

/** Called when a drawer has settled in a completely open state. */
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
getSupportActionBar().setTitle(R.string.drawer_open);
invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
}

/** Called when a drawer has settled in a completely closed state. */
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);

invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
if (mPendingRunnable != null) {
mHandler.post(mPendingRunnable);
mPendingRunnable = null;
}else {
getSupportActionBar().setTitle(mActivityTitle);
}
}
};
mDrawerToggle.setDrawerIndicatorEnabled(true);
mDrawerLayout.setDrawerListener(mDrawerToggle);

getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);

layers = getResources().getStringArray(R.array.layers_array);
mDrawerList = (ListView) findViewById(R.id.navList);
// View header = getLayoutInflater().inflate(R.layout.drawer_list_header, null);
// mDrawerList.addHeaderView(header, null, false);

mArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, layers);

mDrawerList.setAdapter(mArrayAdapter);
// View footerView = ((LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
// R.layout.drawer_list_footer, null, false);
// mDrawerList.addFooterView(footerView);

mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, final int pos, long arg3) {
mDrawerLayout.closeDrawer(Gravity.START);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
selectItem(pos);
}
});
View logoutView = getLayoutInflater().inflate(R.layout.drawer_list_item, null);
TextView textView = (TextView)logoutView.findViewById(R.id.nav_drawer_footer_textview);
textView.setText("Log Out");
mDrawerList.addFooterView(logoutView);

}

private void selectItem(int position) {
Log.d("HELLO", "COUNTED AS SELECTED AND POSITION IS " + position);
Intent intent = null;
switch (position) {
case 0:
intent = new Intent(this, MainActivity.class);
break;
case 1:
intent = new Intent(this, MMLSActivity.class);
break;
case 2:
break;
case 3:
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(BaseActivity.this);
SharedPreferences.Editor editor = prefs.edit();
editor.clear();
editor.commit();
MMUDbHelper mOpenHelper = new MMUDbHelper(BaseActivity.this);
mOpenHelper.onLogout(MainActivity.database);
intent = new Intent(this, LoginActivity.class);
break;
default:
break;
}
if(intent != null) {
final Intent finalIntent = intent;
mPendingRunnable = new Runnable() {
@Override
public void run() {
startActivity(finalIntent);
overridePendingTransition(0, 0);
finish();
}
};
}

}

@Override
public boolean onOptionsItemSelected(MenuItem item) {

if (mDrawerToggle.onOptionsItemSelected(item)) {
return true;
}
return super.onOptionsItemSelected(item);

}

@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
mDrawerToggle.syncState();
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
mDrawerToggle.onConfigurationChanged(newConfig);
}
}
Loading

0 comments on commit 8ae9a22

Please sign in to comment.