use of android.support.v4.app.ActionBarDrawerToggle in project CoCoin by Nightonke.
the class AccountBookMonthViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = this;
setContentView(R.layout.activity_account_book_month_view);
userName = (TextView) findViewById(R.id.user_name);
userEmail = (TextView) findViewById(R.id.user_email);
userName.setTypeface(CoCoinUtil.typefaceLatoRegular);
userEmail.setTypeface(CoCoinUtil.typefaceLatoLight);
User user = BmobUser.getCurrentUser(CoCoinApplication.getAppContext(), User.class);
if (user != null) {
userName.setText(user.getUsername());
userEmail.setText(user.getEmail());
}
mViewPager = (MaterialViewPager) findViewById(R.id.materialViewPager);
View view = mViewPager.getRootView();
TextView title = (TextView) view.findViewById(R.id.logo_white);
title.setTypeface(CoCoinUtil.typefaceLatoLight);
title.setText(SettingManager.getInstance().getAccountBookName());
mViewPager.getPagerTitleStrip().setTypeface(CoCoinUtil.GetTypeface(), Typeface.NORMAL);
setTitle("");
toolbar = mViewPager.getToolbar();
mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (toolbar != null) {
setSupportActionBar(toolbar);
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setHomeButtonEnabled(true);
}
}
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawer, 0, 0);
mDrawer.setDrawerListener(mDrawerToggle);
View logo = findViewById(R.id.logo_white);
if (logo != null) {
logo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mViewPager.notifyHeaderChanged();
}
});
}
monthModeAdapter = new MonthViewFragmentAdapter(getSupportFragmentManager());
mViewPager.getViewPager().setOffscreenPageLimit(monthModeAdapter.getCount());
mViewPager.getViewPager().setAdapter(monthModeAdapter);
mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager());
if (monthModeAdapter.getCount() == 1) {
mViewPager.getPagerTitleStrip().setVisibility(View.INVISIBLE);
}
mViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {
@Override
public HeaderDesign getHeaderDesign(int page) {
return HeaderDesign.fromColorAndDrawable(CoCoinUtil.GetTagColor(RecordManager.TAGS.get(page).getId()), CoCoinUtil.GetTagDrawable(-3));
}
});
recyclerView = (RecyclerView) mDrawer.findViewById(R.id.recycler_view);
drawerMonthViewRecyclerViewAdapter = new DrawerMonthViewRecyclerViewAdapter(mContext);
recyclerView.setAdapter(drawerMonthViewRecyclerViewAdapter);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
recyclerView.setItemAnimator(new DefaultItemAnimator());
drawerMonthViewRecyclerViewAdapter.SetOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
mViewPager.getViewPager().setCurrentItem(position);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
mDrawer.closeDrawers();
}
}, 700);
}
});
profileImage = (CircleImageView) mDrawer.findViewById(R.id.profile_image);
profileImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (SettingManager.getInstance().getLoggenOn()) {
CoCoinUtil.showToast(mContext, R.string.change_logo_tip);
} else {
CoCoinUtil.showToast(mContext, R.string.login_tip);
}
}
});
mDemoSlider = (SliderLayout) findViewById(R.id.slider);
HashMap<String, Integer> urls = CoCoinUtil.GetDrawerTopUrl();
for (String name : urls.keySet()) {
CustomSliderView customSliderView = new CustomSliderView(this);
// initialize a SliderLayout
customSliderView.image(urls.get(name)).setScaleType(BaseSliderView.ScaleType.Fit);
mDemoSlider.addSlider(customSliderView);
}
mDemoSlider.setPresetTransformer(SliderLayout.Transformer.ZoomOut);
mDemoSlider.setCustomAnimation(new DescriptionAnimation());
mDemoSlider.setDuration(4000);
mDemoSlider.setCustomIndicator((PagerIndicator) findViewById(R.id.custom_indicator));
loadLogo();
}
use of android.support.v4.app.ActionBarDrawerToggle in project storymaker by StoryMaker.
the class BaseActivity method setupDrawerLayout.
public void setupDrawerLayout() {
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerContainer = (ViewGroup) findViewById(R.id.left_drawer);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer_white, R.string.open_drawer, R.string.close_drawer) {
/** Called when a drawer has settled in a completely closed state. */
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
// creates call to onPrepareOptionsMenu()
invalidateOptionsMenu();
mDrawerOpen = false;
}
/** Called when a drawer has settled in a completely open state. */
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
// creates call to onPrepareOptionsMenu()
invalidateOptionsMenu();
mDrawerOpen = true;
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
final Activity activity = this;
RelativeLayout llDrawerLogin = (RelativeLayout) findViewById(R.id.llLogin);
ImageButton btnDrawerQuickCaptureVideo = (ImageButton) findViewById(R.id.btnDrawerQuickCaptureVideo);
ImageButton btnDrawerQuickCapturePhoto = (ImageButton) findViewById(R.id.btnDrawerQuickCapturePhoto);
ImageButton btnDrawerQuickCaptureAudio = (ImageButton) findViewById(R.id.btnDrawerQuickCaptureAudio);
Button btnDrawerHome = (Button) findViewById(R.id.btnDrawerHome);
Button btnDrawerCatalog = (Button) findViewById(R.id.btnDrawerCatalog);
// Button btnDrawerProjects = (Button) findViewById(R.id.btnDrawerProjects);
//Button btnDrawerAccount = (Button) findViewById(R.id.btnDrawerAccount);
Button btnDrawerAccounts = (Button) findViewById(R.id.btnDrawerAccounts);
Button btnDrawerExports = (Button) findViewById(R.id.btnDrawerExports);
Button btnDrawerUploadManager = (Button) findViewById(R.id.btnDrawerUploadManager);
Button btnDrawerSettings = (Button) findViewById(R.id.btnDrawerSettings);
Button btnDrawerFeedback = (Button) findViewById(R.id.btnDrawerFeedback);
TextView textViewVersion = (TextView) findViewById(R.id.textViewVersion);
// NEW/CACHEWORD
Button btnDrawerLock = (Button) findViewById(R.id.btnDrawerLock);
// disable button if the user has set a pin
SharedPreferences sp = getSharedPreferences("appPrefs", MODE_PRIVATE);
String cachewordStatus = sp.getString("cacheword_status", "default");
if (cachewordStatus.equals(CACHEWORD_SET)) {
Timber.d("pin set, so remove button");
btnDrawerLock.setVisibility(View.GONE);
} else {
Timber.d("no pin set, so show button");
}
String pkg = getPackageName();
try {
String versionName = getPackageManager().getPackageInfo(pkg, 0).versionName;
int versionCode = getPackageManager().getPackageInfo(pkg, 0).versionCode;
textViewVersion.setText("v" + versionName + " build " + versionCode);
} catch (PackageManager.NameNotFoundException e) {
Timber.e(e, "NameNotFoundException?");
}
updateSlidingMenuWithUserState();
// Set a random profile background
ImageView imageViewProfileBg = (ImageView) findViewById(R.id.imageViewProfileBg);
int profileBg = (int) (Math.random() * 2);
switch(profileBg) {
case 0:
imageViewProfileBg.setImageResource(R.drawable.profile_bg1);
break;
case 1:
imageViewProfileBg.setImageResource(R.drawable.profile_bg2);
break;
case 2:
imageViewProfileBg.setImageResource(R.drawable.profile_bg3);
break;
}
llDrawerLogin.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mDrawerLayout.closeDrawers();
Intent i = new Intent(activity, ConnectAccountActivity.class);
activity.startActivity(i);
}
});
btnDrawerHome.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mDrawerLayout.closeDrawers();
Intent i = new Intent(activity, HomeActivity.class);
activity.startActivity(i);
}
});
btnDrawerCatalog.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mDrawerLayout.closeDrawers();
Intent i = new Intent(activity, CatalogActivity.class);
activity.startActivity(i);
}
});
btnDrawerExports.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mDrawerLayout.closeDrawers();
Intent i = new Intent(activity, ProjectsActivity.class);
activity.startActivity(i);
}
});
btnDrawerAccounts.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mDrawerLayout.closeDrawers();
Intent i = new Intent(activity, AccountsActivity.class);
activity.startActivity(i);
}
});
btnDrawerUploadManager.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mDrawerLayout.closeDrawers();
Toast.makeText(getApplicationContext(), "Not yet implemented", Toast.LENGTH_LONG).show();
// Intent i = new Intent(activity, AccountsActivity.class);
// activity.startActivity(i);
}
});
btnDrawerSettings.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mDrawerLayout.closeDrawers();
Intent i = new Intent(activity, SimplePreferences.class);
activity.startActivity(i);
}
});
btnDrawerFeedback.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mDrawerLayout.closeDrawers();
FeedbackManager.register(activity, AppConstants.HOCKEY_APP_ID, null);
FeedbackManager.showFeedbackActivity(activity);
}
});
// NEW/CACHEWORD
btnDrawerLock.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// if there has been no first lock, set status so user will be prompted to create a pin
SharedPreferences sp = getSharedPreferences("appPrefs", MODE_PRIVATE);
String cachewordStatus = sp.getString("cacheword_status", "default");
if (cachewordStatus.equals(CACHEWORD_UNSET)) {
// set flag so user will be prompted to create a pin
setPin = true;
Timber.d("set cacheword first lock flag");
}
mCacheWordHandler.lock();
}
});
}
use of android.support.v4.app.ActionBarDrawerToggle in project AnimeTaste by daimajia.
the class StartActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mContext = this;
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
mVideoList = (ListView) findViewById(R.id.videoList);
mDrawerList = (ListView) findViewById(R.id.function_list);
mDrawer = (LinearLayout) findViewById(R.id.drawer);
mLayoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mCategoryList = (ListView) findViewById(R.id.category_list);
mFooterView = mLayoutInflater.inflate(R.layout.load_item, null);
mLoadProgress = (ProgressBar) mFooterView.findViewById(R.id.loading);
mLoadText = (TextView) mFooterView.findViewById(R.id.load_text);
mVideoList.addFooterView(mFooterView);
mVideoList.setOnScrollListener(this);
mDrawer.setOnTouchListener(this);
View headerView = mLayoutInflater.inflate(R.layout.gallery_item, null, false);
mVideoList.addHeaderView(headerView);
mRecommendPager = (ViewPager) headerView.findViewById(R.id.pager);
mRecommendPager.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
PointF downP = new PointF();
PointF curP = new PointF();
int act = event.getAction();
if (act == MotionEvent.ACTION_DOWN || act == MotionEvent.ACTION_MOVE || act == MotionEvent.ACTION_UP) {
((ViewGroup) v).requestDisallowInterceptTouchEvent(true);
if (downP.x == curP.x && downP.y == curP.y) {
return false;
}
}
return false;
}
});
mRecommendIndicator = (UnderlinePageIndicator) headerView.findViewById(R.id.indicator);
if (getIntent().hasExtra("Success")) {
init(getIntent());
} else {
Toast.makeText(mContext, R.string.init_failed, Toast.LENGTH_SHORT).show();
finish();
}
mDrawerAapter = new SimpleAdapter(this, getDrawerItems(), R.layout.drawer_item, new String[] { "img", "title" }, new int[] { R.id.item_icon, R.id.item_name });
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_action_navigation_menu, R.string.app_name, R.string.app_name) {
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
if (mPreviousType != mType || mPreviousCategoryId != mCategoryId) {
mCurrentPage = 1;
mIsEnd = false;
mVideoAdapter.removeAllData();
mFooterView.findViewById(R.id.loading).setVisibility(View.VISIBLE);
mFooterView.findViewById(R.id.load_text).setVisibility(View.INVISIBLE);
triggerApiConnector();
}
}
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
mPreviousType = mType;
mPreviousCategoryId = mCategoryId;
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
mDrawerList.setAdapter(mDrawerAapter);
mDrawerList.setOnItemClickListener(this);
ViewUtils.setListViewHeightBasedOnChildren(mDrawerList);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayUseLogoEnabled(true);
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);
getSupportActionBar().setLogo(R.drawable.rsz_ab_icon);
rateForUsOrCheckUpdate();
showWhatsNew();
}
use of android.support.v4.app.ActionBarDrawerToggle in project cw-omnibus by commonsguy.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
drawer = (ListView) findViewById(R.id.drawer);
drawer.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
String[] rows = getResources().getStringArray(R.array.drawer_rows);
drawer.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_row, rows));
drawer.setOnItemClickListener(this);
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
toggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close);
drawerLayout.setDrawerListener(toggle);
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
getFragmentManager().addOnBackStackChangedListener(this);
if (getFragmentManager().findFragmentById(R.id.content) == null) {
showLorem();
}
}
use of android.support.v4.app.ActionBarDrawerToggle in project SimplifyReader by chentao0707.
the class HomeActivity method initializeViews.
@Override
public void initializeViews(List<BaseLazyFragment> fragments, List<NavigationEntity> navigationList) {
mActionBarDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.drawer_open, R.string.drawer_close) {
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
setTitle(getString(R.string.app_name));
}
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
if (null != mNavListAdapter) {
setTitle(mNavListAdapter.getItem(mCurrentMenuCheckedPos).getName());
}
}
};
mActionBarDrawerToggle.setDrawerIndicatorEnabled(true);
mDrawerLayout.setDrawerListener(mActionBarDrawerToggle);
if (null != fragments && !fragments.isEmpty()) {
mViewPager.setEnableScroll(false);
mViewPager.setOffscreenPageLimit(fragments.size());
mViewPager.setAdapter(new VPFragmentAdapter(getSupportFragmentManager(), fragments));
}
mNavListAdapter = new ListViewDataAdapter<NavigationEntity>(new ViewHolderCreator<NavigationEntity>() {
@Override
public ViewHolderBase<NavigationEntity> createViewHolder(int position) {
return new ViewHolderBase<NavigationEntity>() {
ImageView itemIcon;
TextView itemName;
@Override
public View createView(LayoutInflater layoutInflater) {
View convertView = layoutInflater.inflate(R.layout.list_item_navigation, null);
itemIcon = ButterKnife.findById(convertView, R.id.list_item_navigation_icon);
itemName = ButterKnife.findById(convertView, R.id.list_item_navigation_name);
return convertView;
}
@Override
public void showData(int i, NavigationEntity navigationEntity) {
itemIcon.setImageResource(navigationEntity.getIconResId());
itemName.setText(navigationEntity.getName());
if (mCurrentMenuCheckedPos == i) {
// checked
itemName.setTextColor(getResources().getColor(mCheckedListItemColorResIds[i]));
} else {
// unchecked
itemName.setTextColor(getResources().getColor(android.R.color.black));
}
}
};
}
});
mNavListView.setAdapter(mNavListAdapter);
mNavListAdapter.getDataList().addAll(navigationList);
mNavListAdapter.notifyDataSetChanged();
setTitle(mNavListAdapter.getItem(mCurrentMenuCheckedPos).getName());
mNavListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mCurrentMenuCheckedPos = position;
mNavListAdapter.notifyDataSetChanged();
mDrawerLayout.closeDrawer(Gravity.LEFT);
mViewPager.setCurrentItem(mCurrentMenuCheckedPos, false);
}
});
}
Aggregations