NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package com.inkbridge.inkbridge;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.support.design.bottomappbar.BottomAppBar;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

import com.google.firebase.auth.FirebaseAuth;

import java.util.ArrayList;

import javax.security.auth.login.LoginException;

import static android.support.design.bottomappbar.BottomAppBar.FAB_ALIGNMENT_MODE_CENTER;
import static android.support.design.bottomappbar.BottomAppBar.FAB_ALIGNMENT_MODE_END;

public class ActivityMain extends AppCompatActivity {

private static final String TAG = "main";
private BottomAppBar bottomAppBar;
private ArrayList<Fragment> fragmentList;
private String ch = "0";
private FragmentManager fragmentManager;
private FloatingActionButton fab;
private static final int PERMISSION_REQUEST_CODE = 1;


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

setViews();

setSupportActionBar(bottomAppBar);

setFragment("0");

onFabClick();

checkForStoragePermission();

}

private void checkForStoragePermission() {

if (Build.VERSION.SDK_INT >= 23) {
if (checkPermission()) {
// Code for above or equal 23 API Oriented Device
// Your Permission granted already .Do next code
Log.wtf(TAG, "Permission already granted");
//Log.wtf(TAG, localStoragePath);

} else {
Log.wtf(TAG, "Request permission");
requestPermission(); // Code for permission
}
} else {
Log.wtf(TAG, "some error occured");
// Code for Below 23 API Oriented Device
// Do next code
}

}

private void requestPermission() {
try {
ActivityCompat.requestPermissions(ActivityMain.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
PERMISSION_REQUEST_CODE);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}

private boolean checkPermission() {
int result = ContextCompat.checkSelfPermission(ActivityMain.this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (result == PackageManager.PERMISSION_GRANTED) {
return true;
} else {
return false;
}
}

private void onFabClick() {
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int fab = bottomAppBar.getFabAlignmentMode();
if(fab == 0){
startActivity(new Intent(ActivityMain.this, ActivityTyper.class));
}
else if(fab == 1){
setFragment("0");
}

}
});
}

public void setViews(){
bottomAppBar = findViewById(R.id.bottom_app_bar);
bottomAppBar.setHideOnScroll(true);
fragmentList = new ArrayList<>();
fragmentList.add(new FragmentNewsFeed());
fragmentList.add(new FragmentNewConsignment());
fragmentList.add(new FragmentNotificationNew());
fragmentList.add(new FragmentProfile());
fragmentManager = getSupportFragmentManager();
fab = findViewById(R.id.fab);
}

protected void setFragment(String tag) {

if(tag.equals("1")) {
bottomAppBar.setFabAlignmentMode((FAB_ALIGNMENT_MODE_END));
fab.setImageResource(R.drawable.icon_back);
}
else {
bottomAppBar.setFabAlignmentMode((FAB_ALIGNMENT_MODE_CENTER));
fab.setImageResource(R.drawable.icon_plus);
}

FragmentTransaction transaction = fragmentManager.beginTransaction();
if (tag.compareTo(ch) > 0)
transaction.setCustomAnimations(R.anim.enter_right, R.anim.exit_left).commit();
else if (tag.compareTo(ch) < 0)
transaction.setCustomAnimations(R.anim.enter_left, R.anim.exit_right).commit();
else
transaction.commit();
for (int i = 0; i < fragmentList.size(); i++) {
if (tag.equals(String.valueOf(i))) {
if (fragmentManager.findFragmentByTag(String.valueOf(i)) != null) {
transaction.show(fragmentManager.findFragmentByTag(String.valueOf(i)));
} else
transaction.add(R.id.fragment_container, fragmentList.get(i), String.valueOf(i));
} else if (fragmentManager.findFragmentByTag(String.valueOf(i)) != null)
transaction.hide(fragmentManager.findFragmentByTag(String.valueOf(i)));

}
ch = tag;

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.bottomappbar_menu_primary,menu);
return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()){

case android.R.id.home:
BottomNavigationDrawerFragment bottomNavigation = new BottomNavigationDrawerFragment();
bottomNavigation.show(getSupportFragmentManager(),bottomNavigation.getTag());
break;

case R.id.app_bar_search:
print("Search");
break;
}
return super.onOptionsItemSelected(item);
}

public void print(String s){
Toast.makeText(this, s, Toast.LENGTH_SHORT).show();
}


public void finishActivity(){

FirebaseAuth.getInstance().signOut();
Intent intent = new Intent(getApplicationContext(), ActivityLogin.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}

}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.