Skip to content

Commit

Permalink
material design
Browse files Browse the repository at this point in the history
  • Loading branch information
grumoon committed Jan 11, 2015
1 parent 69c9048 commit 87b70a1
Show file tree
Hide file tree
Showing 19 changed files with 479 additions and 78 deletions.
3 changes: 3 additions & 0 deletions android-Ultra-Pull-To-Refresh-demo/app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
<orderEntry type="library" exported="" name="ultra-ptr-1.0.5" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" name="universal-image-loader-1.9.3" level="project" />
</component>
</module>

6 changes: 5 additions & 1 deletion android-Ultra-Pull-To-Refresh-demo/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {

defaultConfig {
applicationId "com.grumoon.androidultrapulltorefreshdemo"
minSdkVersion 15
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0"
Expand All @@ -22,5 +22,9 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:cardview-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
compile 'in.srain.cube:ultra-ptr:1.0.5@aar'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
compile 'com.android.support:support-v4:21.0.3'
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.grumoon.androidultrapulltorefreshdemo" >
package="com.grumoon.androidultrapulltorefreshdemo">

<uses-sdk android:minSdkVersion="8" />

<!-- Include following permission if you load images from Internet -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Include following permission if you want to cache images on SD card -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:theme="@style/AppTheme">
<activity
android:name=".AppHome"
android:label="@string/app_name" >
android:name=".ui.AppHome"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package com.grumoon.androidultrapulltorefreshdemo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.grumoon.androidultrapulltorefreshdemo.R;
import com.grumoon.androidultrapulltorefreshdemo.util.DataUtil;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Created by grumoon on 15/1/11.
*/
public class DrawerMenuAdapter extends BaseAdapter {

private int selectedIndex = 0;

private List<HashMap<String, String>> menuList;
private LayoutInflater layoutInflater;

public DrawerMenuAdapter(Context context, List<HashMap<String, String>> menuList) {
this.layoutInflater = LayoutInflater.from(context);
this.menuList = menuList;
}

@Override
public int getCount() {
if (menuList == null) {
return 0;
}
return menuList.size();
}

@Override
public Object getItem(int position) {
if (menuList == null || position > menuList.size() - 1) {
return null;
}
return menuList.get(position);
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder = null;

if (convertView == null) {
viewHolder = new ViewHolder();
convertView = layoutInflater.inflate(R.layout.fragment_drawer_menu_item, parent, false);
viewHolder.tvGroupName = (TextView) convertView.findViewById(R.id.tv_group_name);
viewHolder.tvItemName = (TextView) convertView.findViewById(R.id.tv_item_name);
convertView.setTag(viewHolder);

} else {
viewHolder = (ViewHolder) convertView.getTag();
}

Map<String, String> menuItem = menuList.get(position);
if (menuItem.containsKey(DataUtil.MENU_KEY_GROUP_NAME)) {
viewHolder.tvGroupName.setText(menuItem.get(DataUtil.MENU_KEY_GROUP_NAME));
viewHolder.tvGroupName.setVisibility(View.VISIBLE);
} else {
viewHolder.tvGroupName.setVisibility(View.GONE);
}

viewHolder.tvItemName.setText(menuItem.get(DataUtil.MENU_KEY_ITEM_NAME));

if (position == selectedIndex) {
viewHolder.tvItemName.setBackgroundResource(R.drawable.drawer_menu_item_selected_bg);
} else {
viewHolder.tvItemName.setBackgroundResource(R.drawable.drawer_menu_item_bg);
}

return convertView;
}


static class ViewHolder {
TextView tvGroupName;
TextView tvItemName;
}


public void setSelectedIndex(int position) {
if (menuList != null && position < menuList.size()) {
selectedIndex = position;
notifyDataSetChanged();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.grumoon.androidultrapulltorefreshdemo.ui;

import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;

import com.grumoon.androidultrapulltorefreshdemo.R;

public class AppHome extends ActionBarActivity {


private Toolbar toolbar;
private DrawerLayout dlHome;
private ActionBarDrawerToggle drawerToggle;


private FragmentManager fm;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_app_home);
initView();
}

private void initView() {

toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

dlHome = (DrawerLayout) findViewById(R.id.dl_home);


getSupportActionBar().setDisplayHomeAsUpEnabled(true);

drawerToggle = new ActionBarDrawerToggle(this, dlHome, toolbar, 0, 0);
drawerToggle.syncState();
dlHome.setDrawerListener(drawerToggle);


}


public void drawerMenuClose() {
dlHome.closeDrawers();
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.grumoon.androidultrapulltorefreshdemo.ui;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;

import com.grumoon.androidultrapulltorefreshdemo.R;
import com.grumoon.androidultrapulltorefreshdemo.adapter.DrawerMenuAdapter;
import com.grumoon.androidultrapulltorefreshdemo.util.DataUtil;


/**
* A simple {@link Fragment} subclass.
*/
public class DrawerMenuFragment extends Fragment {

private ListView lvMenu;

private DrawerMenuAdapter adapter;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_drawer_menu, container, false);
initView(v);
return v;
}


private void initView(View v) {

lvMenu = (ListView) v.findViewById(R.id.lv_menu);
adapter = new DrawerMenuAdapter(getActivity(), DataUtil.getMenuList());
lvMenu.setAdapter(adapter);

lvMenu.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
adapter.setSelectedIndex(position);
((AppHome) getActivity()).drawerMenuClose();
}
});
}


}
Loading

0 comments on commit 87b70a1

Please sign in to comment.